Add devcontainer

This commit is contained in:
Kevin Kandlbinder 2023-10-19 12:13:21 +00:00
parent 99fee36e74
commit 077e6a9ac7
4 changed files with 105 additions and 0 deletions

4
.devcontainer/.env Normal file
View file

@ -0,0 +1,4 @@
ME_CONFIG_MONGODB_URL=mongodb://mongo:27017/
MONGODB_URI=mongodb://mongo:27017/
REDIS_ADDR=redis:6379
DEV=true

18
.devcontainer/Dockerfile Normal file
View file

@ -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 <your-package-list-here>
# [Optional] Uncomment the next lines to use go get to install anything else you need
# USER vscode
# RUN go get -x <your-dependency-or-tool>
# 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 <your-package-here>" 2>&1

View file

@ -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"
}
}

View file

@ -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: