From 2e50dd447d38677ff686a4ec9ee3a88acfd5ec60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Sun, 29 Oct 2023 17:13:32 +0100 Subject: [PATCH] use compose environment for devcontainer - add redis container --- api/.devcontainer/devcontainer.json | 18 +++------------- api/.devcontainer/docker-compose.yml | 32 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 15 deletions(-) create mode 100644 api/.devcontainer/docker-compose.yml diff --git a/api/.devcontainer/devcontainer.json b/api/.devcontainer/devcontainer.json index 030118d..2ee4cb2 100644 --- a/api/.devcontainer/devcontainer.json +++ b/api/.devcontainer/devcontainer.json @@ -2,21 +2,9 @@ // README at: https://github.com/devcontainers/templates/tree/main/src/python { "name": "Advent22 API", - "build": { - "dockerfile": "Dockerfile", - "context": "..", - "args": { - // Update 'VARIANT' to pick a Python version. - // Append -bullseye or -buster to pin to an OS version. - // Use -bullseye variants on local on arm64/Apple Silicon. - "VARIANT": "3.11-bookworm", - // Options - "NODE_VERSION": "none" - } - }, - "containerEnv": { - "TZ": "Europe/Berlin" - }, + "dockerComposeFile": "docker-compose.yml", + "service": "api", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", // Configure tool-specific properties. "customizations": { // Configure properties specific to VS Code. diff --git a/api/.devcontainer/docker-compose.yml b/api/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..ea9650f --- /dev/null +++ b/api/.devcontainer/docker-compose.yml @@ -0,0 +1,32 @@ +version: "3.8" + +services: + api: + build: + context: "." + dockerfile: "Dockerfile" + args: + # Update 'VARIANT' to pick a Python version. + # Append -bookworm, -bullseye or -buster to pin to an OS version. + # Use -bookworm or -bullseye variants on local on arm64/Apple Silicon. + VARIANT: "3.11-bookworm" + NODE_VERSION: "none" + + environment: + TZ: "Europe/Berlin" + + volumes: + - "../..:/workspaces:cached" + + # Overrides default command so things don't shut down after the process ends. + command: "sleep infinity" + + # Runs app on the same network as the redis container, allows "forwardPorts" in devcontainer.json function. + network_mode: "service:redis" + + # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + + redis: + image: "redis:7" + restart: "unless-stopped" \ No newline at end of file