From 19a5b79554f631085ee3ef70ac2e0f529bb5d037 Mon Sep 17 00:00:00 2001 From: Jake Morrison Date: Sat, 6 Jan 2024 13:29:52 -0600 Subject: [PATCH] Set up devcontainer --- .devcontainer/devcontainer.json | 55 ++++++++++++++++++++++++++++++++ .devcontainer/docker-compose.yml | 27 ++++++++++++++++ docker-compose.gha.yml | 35 ++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..aa5e265 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,55 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose +{ + "name": "foo-app", + + // Update the 'dockerComposeFile' list if you have more compose files or use different names. + // The .devcontainer/docker-compose.yml file contains any overrides you need/want to make. + "dockerComposeFile": [ + "../docker-compose.gha.yml", + "docker-compose.yml" + ], + + // The 'service' property is the name of the service for the container that VS Code should + // use. Update this value and .devcontainer/docker-compose.yml to the real service name. + "service": "dev", + + // The optional 'workspaceFolder' property is the path VS Code should open by default when + // connected. This is typically a file mount in .devcontainer/docker-compose.yml + // "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}" + "workspaceFolder": "/app", + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "jakebecker.elixir-ls" + ], + + "customizations": { + "vscode": { + "extensions": [ + "ms-vscode-remote.remote-containers" + ] + } + }, + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + "forwardPorts": [4000, 4001, 5432], + + // Uncomment the next line if you want start specific services in your Docker Compose config. + "runServices": ["dev"], + + // Uncomment the next line if you want to keep your containers running after VS Code shuts down. + // "shutdownAction": "none", + + // Uncomment the next line to run commands after the container is created. + // "postCreateCommand": "cat /etc/os-release", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. + "remoteUser": "nonroot" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..45eed6a --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,27 @@ +--- +version: '3.9' +services: + # Update this to the name of the service you want to work with in your docker-compose.yml file + dev: + # Uncomment if you want to override the service's Dockerfile to one in the .devcontainer + # folder. Note that the path of the Dockerfile and context is relative to the *primary* + # docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile" + # array). The sample below assumes your primary file is in the root of your project. + # + # build: + # context: . + # dockerfile: .devcontainer/Dockerfile + + # volumes: + # # Update this to wherever you want VS Code to mount the folder of your project + # - ..:/app:cached + + # Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust. + # cap_add: + # - SYS_PTRACE + # security_opt: + # - seccomp:unconfined + + # Overrides default command so things don't shut down after the process ends. + command: /bin/sh -c "while sleep 1000; do :; done" + # command: sleep infinity diff --git a/docker-compose.gha.yml b/docker-compose.gha.yml index f15b8b3..817c508 100644 --- a/docker-compose.gha.yml +++ b/docker-compose.gha.yml @@ -71,6 +71,41 @@ services: # aws-otel-collector: # condition: service_healthy + # Development image + dev: + image: "${REGISTRY:-docker.io/}${IMAGE_OWNER}/${IMAGE_NAME}:dev" + build: + dockerfile: ${DOCKER_FILE:-deploy/debian.Dockerfile} + target: dev + args: + BUILDKIT_INLINE_CACHE: "1" + REGISTRY: ${REGISTRY:-docker.io/} + PUBLIC_REGISTRY: ${REGISTRY:-docker.io/} + context: . + # secrets: + # - oban_license_key + # - oban_key_fingerprint + # - access_token + # VSCode devcontainer needs something running + # command: /bin/sh -c "while sleep 1000; do :; done" + environment: + - DATABASE_DB + - DATABASE_HOST=${DATABASE_HOST:-postgres} + - DATABASE_URL + - SECRET_KEY_BASE=${SECRET_KEY_BASE:-0cSFk8v5IsZIIGCjY+X66l5xULUl/2mczI4Eqf7slpyns5nBkhegDn6YH9th+5D2} + ports: + - '4000:4000' + stdin_open: true + tty: true + cap_add: + - CAP_SYS_ADMIN + volumes: + - ".:/app:delegated" + # - 'nfsmount:/app' + depends_on: + postgres: + condition: service_healthy + # https://github.com/aws-observability/aws-otel-collector/blob/main/docs/developers/docker-demo.md aws-otel-collector: image: public.ecr.aws/aws-observability/aws-otel-collector:latest