diff options
author | Davey Shafik <me@daveyshafik.com> | 2020-08-11 04:46:52 +0000 |
---|---|---|
committer | Davey Shafik <me@daveyshafik.com> | 2020-08-11 04:48:49 +0000 |
commit | 54d71115ffd916a1e4c630cc74216de8db2c0ac5 (patch) | |
tree | b34035ce457ce11541e0b3eda8eb31ca123e5312 | |
parent | da7457e53c22b392ce1c28e9929e34cb698a945e (diff) | |
download | php7-mysql-shim-54d71115ffd916a1e4c630cc74216de8db2c0ac5.zip php7-mysql-shim-54d71115ffd916a1e4c630cc74216de8db2c0ac5.tar.gz php7-mysql-shim-54d71115ffd916a1e4c630cc74216de8db2c0ac5.tar.bz2 |
Add CodeSpaces .devcontainer config
-rw-r--r-- | .devcontainer/Dockerfile | 30 | ||||
-rw-r--r-- | .devcontainer/devcontainer.json | 25 | ||||
-rw-r--r-- | .devcontainer/docker-compose.yml | 41 |
3 files changed, 96 insertions, 0 deletions
diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..b8e9242 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,30 @@ +# Update the VARIANT arg in docker-compose.yml to pick a PHP version: 7, 7.4, 7.3 +ARG VARIANT=7 +FROM mcr.microsoft.com/vscode/devcontainers/php:${VARIANT} + +# Install MariaDB client +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get install -y mariadb-client \ + && apt-get clean -y && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/library-scripts + +# Update args in docker-compose.yaml to set the UID/GID of the "vscode" user. +ARG USER_UID=1000 +ARG USER_GID=$USER_UID +RUN if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \ + groupmod --gid $USER_GID vscode \ + && usermod --uid $USER_UID --gid $USER_GID vscode \ + && chmod -R $USER_UID:$USER_GID /home/vscode \ + && chmod -R $USER_UID:root /usr/local/share/nvm; \ + fi + +# [Optional] Install a version of Node.js using nvm for front end dev +ARG INSTALL_NODE="true" +ARG NODE_VERSION="lts/*" +RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends <your-package-list-here> + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
\ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..dd9162b --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,25 @@ +// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.112.0/containers/php-7 +{ + "name": "PHP & MariaDB", + "dockerComposeFile": "docker-compose.yml", + "service": "php", + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "felixfbecker.php-debug", + "felixfbecker.php-intellisense", + "mtxr.sqltools", + "mtxr.sqltools-driver-mysql" + ], + + "workspaceFolder": "/workspace", + + // Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. + // "remoteUser": "vscode", +}
\ No newline at end of file diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..8491159 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,41 @@ +version: "3" + +services: + php: + # Uncomment the next line to use a non-root user for all processes. + # See https://aka.ms/vscode-remote/containers/non-root for details. + # user: vscode + + build: + context: . + dockerfile: Dockerfile + args: + # Update VARIANT to pick a PHP version: 7, 7.4, 7.3 + VARIANT: "7.4" + INSTALL_NODE: "true" + NODE_VERSION: "lts/*" + USER_UID: 1000 + USER_GID: 1000 + + volumes: + - ..:/workspace:cached + + ports: + # For use with PHP (e.g. `php -S localhost:8080`) + - "8080:8080" + + # Overrides default command so things don't shut down after the process ends. + command: sleep infinity + + mariadb: + image: mariadb:10.4 + expose: + # Expose mariadb port to php service (Access as hostname "mariadb" from within php container) + - "3306" + # Uncomment to allow access to mariadb from external tools + # ports: + # - "3306:3306" + restart: unless-stopped + environment: + MYSQL_ROOT_PASSWORD: + MYSQL_DATABASE: shim_test |