From 077e6a9ac70dd97018e634954dc71367d1538e65 Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 19 Oct 2023 12:13:21 +0000 Subject: [PATCH] Add devcontainer --- .devcontainer/.env | 4 +++ .devcontainer/Dockerfile | 18 ++++++++++++ .devcontainer/devcontainer.json | 33 +++++++++++++++++++++ .devcontainer/docker-compose.yml | 50 ++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 .devcontainer/.env create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml diff --git a/.devcontainer/.env b/.devcontainer/.env new file mode 100644 index 0000000..070029c --- /dev/null +++ b/.devcontainer/.env @@ -0,0 +1,4 @@ +ME_CONFIG_MONGODB_URL=mongodb://mongo:27017/ +MONGODB_URI=mongodb://mongo:27017/ +REDIS_ADDR=redis:6379 +DEV=true \ No newline at end of file diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..5ab0602 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,18 @@ +ARG VARIANT=1.21 +FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT} + +# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 +ARG NODE_VERSION="21" +RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /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 + +# [Optional] Uncomment the next lines to use go get to install anything else you need +# USER vscode +# RUN go get -x +# USER root + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..0194790 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,33 @@ +{ + "name": "Go & MongoDB", + "dockerComposeFile": "docker-compose.yml", + "service": "app", + "workspaceFolder": "/workspace", + + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Set *default* container specific settings.json values on container create. + "settings": { + "go.toolsManagement.checkForUpdates": "local", + "go.useLanguageServer": true, + "go.gopath": "/go", + "go.goroot": "/usr/local/go" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "golang.Go", + "ms-azuretools.vscode-docker" + ] + } + }, + "forwardPorts": [3001], + "postCreateCommand": "go version && go mod download", + "remoteUser": "vscode", + "features": { + "kubectl-helm-minikube": "latest", + "github-cli": "latest" + } +} \ No newline at end of file diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..cc3e3c7 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,50 @@ +version: '3.8' + +services: + app: + build: + context: . + dockerfile: Dockerfile + args: + VARIANT: 1 + # NODE_VERSION: "lts/*" + env_file: + - .env + +# security_opt: +# - seccomp:unconfined +# cap_add: +# - SYS_PTRACE + + volumes: + - ..:/workspace:cached + + command: sleep infinity + # user: vscode + + redis: + image: redis + volumes: + - redis-data:/data + env_file: + - .env + + mongo: + image: mongo + volumes: + - mongo-data:/data/db + env_file: + - .env + + mongo-express: + image: mongo-express + ports: + - "8081:8081" + env_file: + - .env + environment: + ME_CONFIG_MONGODB_URL: mongodb://mongo:27017/ + +volumes: + redis-data: + mongo-data: \ No newline at end of file