summaryrefslogtreecommitdiffstats
path: root/.devcontainer
diff options
context:
space:
mode:
Diffstat (limited to '.devcontainer')
-rw-r--r--.devcontainer/Dockerfile40
-rw-r--r--.devcontainer/devcontainer.json29
-rw-r--r--.devcontainer/docker-compose.yml47
-rwxr-xr-x.devcontainer/install-composer.sh17
4 files changed, 133 insertions, 0 deletions
diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
new file mode 100644
index 0000000..962fb6f
--- /dev/null
+++ b/.devcontainer/Dockerfile
@@ -0,0 +1,40 @@
+# 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
+
+# Install PHP Extensions
+RUN docker-php-ext-install mysqli
+
+# Install Composer
+ADD ./install-composer.sh /usr/local/share/install-composer.sh
+RUN /usr/local/share/install-composer.sh
+
+# Add git auto-complete to bash
+RUN echo "source /usr/share/bash-completion/completions/git" >> ~/.bashrc
+
+# 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..f9e1885
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,29 @@
+// 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",
+ "bmewburn.vscode-intelephense-client",
+ "eamodio.gitlens",
+ "hbenl.vscode-test-explorer",
+ "recca0120.vscode-phpunit"
+ ],
+
+ "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..9ca7a4a
--- /dev/null
+++ b/.devcontainer/docker-compose.yml
@@ -0,0 +1,47 @@
+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
+
+ links:
+ - mariadb
+
+ environment:
+ MYSQL_HOST: mariadb
+
+ 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_ALLOW_EMPTY_PASSWORD: 1
+ MYSQL_DATABASE: shim_test
diff --git a/.devcontainer/install-composer.sh b/.devcontainer/install-composer.sh
new file mode 100755
index 0000000..ff40a28
--- /dev/null
+++ b/.devcontainer/install-composer.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)"
+php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
+ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
+
+if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
+then
+ >&2 echo 'ERROR: Invalid installer checksum'
+ rm composer-setup.php
+ exit 1
+fi
+
+php composer-setup.php --install-dir=/usr/local/bin --filename=composer --quiet
+RESULT=$?
+rm composer-setup.php
+exit $RESULT \ No newline at end of file