From 05cb7fa4aee5e1dd5afda26f8267cc0103e84c41 Mon Sep 17 00:00:00 2001 From: Sven Marnach Date: Thu, 21 Dec 2023 13:13:44 +0100 Subject: [PATCH 1/3] bug-1871345: Merge docker-compose files. --- .devcontainer/devcontainer.json | 3 +-- .devcontainer/docker-compose.yml | 19 ------------------- docker-compose.yml | 28 +++++++++++++++------------- 3 files changed, 16 insertions(+), 34 deletions(-) delete mode 100644 .devcontainer/docker-compose.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 46af42ab2..217d7524b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,8 +1,7 @@ { "name": "Tecken", "dockerComposeFile": [ - "../docker-compose.yml", - "docker-compose.yml" + "../docker-compose.yml" ], "service": "devcontainer", "runServices": [ diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml deleted file mode 100644 index ecf6d4388..000000000 --- a/.devcontainer/docker-compose.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -# Dev container https://containers.dev/, e.g. for VS Code -version: '2.4' -services: - devcontainer: - extends: - file: "docker-compose.yml" - service: test - build: - dockerfile: .devcontainer/Dockerfile - image: tecken-devcontainer - links: - - db - - fakesentry - - redis-cache - - localstack - - oidcprovider - - statsd - entrypoint: ["sleep", "inf"] diff --git a/docker-compose.yml b/docker-compose.yml index b28f8dbec..94f47e7eb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,9 +16,6 @@ services: web: extends: service: base - depends_on: - - db - - redis-cache ports: - "${EXPOSE_TECKEN_PORT:-8000}:8000" links: @@ -33,7 +30,7 @@ services: command: ["web", "--dev"] # Container specifically for running tests. - test: + test-ci: extends: service: base env_file: @@ -43,19 +40,24 @@ services: - db - fakesentry - redis-cache + - localstack + - oidcprovider + - statsd + + test: + extends: + service: test-ci volumes: - $PWD:/app - test-ci: + # Dev container https://containers.dev/, e.g. for VS Code + devcontainer: extends: - service: base - env_file: - - docker/config/local_dev.env - - docker/config/test.env - links: - - db - - fakesentry - - redis-cache + service: test + build: + dockerfile: .devcontainer/Dockerfile + image: tecken-devcontainer + entrypoint: ["sleep", "inf"] # Web container is a prod-like fully-functioning container. gunicorn: From d2671d9e30b4420b8b6edf4ff85f6aa21448ea7d Mon Sep 17 00:00:00 2001 From: Sven Marnach Date: Thu, 21 Dec 2023 13:14:32 +0100 Subject: [PATCH 2/3] bug-1871345: Set build arguments in docker-compose.yml. --- Makefile | 13 +++---------- docker-compose.yml | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index c341666f3..adaf8e4af 100644 --- a/Makefile +++ b/Makefile @@ -7,12 +7,6 @@ include .env export -# Set these in the environment to override them. This is helpful for -# development if you have file ownership problems because the user -# in the container doesn't match the user on your host. -USE_UID ?= 10001 -USE_GID ?= 10001 - DOCKER := $(shell which docker) DC=${DOCKER} compose @@ -45,8 +39,7 @@ slick.sh: .PHONY: build build: .env ## | Build docker images. - ${DC} build --build-arg userid=${USE_UID} --build-arg groupid=${USE_GID} --progress plain base frontend - ${DC} build --progress plain fakesentry ${SERVICES} + ${DC} build --progress plain base frontend fakesentry ${SERVICES} touch .docker-build .PHONY: setup @@ -97,8 +90,8 @@ testshell: .env .docker-build ## | Open shell in test environment. .PHONY: docs docs: .env .docker-build ## | Build docs. - ${DC} run --rm --user ${USE_UID} --no-deps web bash make -C docs/ clean - ${DC} run --rm --user ${USE_UID} --no-deps web bash make -C docs/ html + ${DC} run --rm --no-deps web bash make -C docs/ clean + ${DC} run --rm --no-deps web bash make -C docs/ html .PHONY: lint lint: .env .docker-build ## | Lint code. diff --git a/docker-compose.yml b/docker-compose.yml index 94f47e7eb..1582a5ee5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,6 +7,9 @@ services: build: context: . dockerfile: docker/Dockerfile + args: + userid: ${USE_UID:-10001} + groupid: ${USE_GID:-10001} image: tecken:build env_file: - docker/config/local_dev.env @@ -70,10 +73,18 @@ services: - redis-cache command: web - frontend: + # Same as 'frontend' but no volumes or command + frontend-ci: build: context: . dockerfile: frontend/Dockerfile + args: + userid: ${USE_UID:-10001} + groupid: ${USE_GID:-10001} + + frontend: + extends: + frontend-ci environment: - NODE_ENV=development ports: @@ -83,12 +94,6 @@ services: - $PWD/frontend:/app command: start - # Same as 'frontend' but no volumes or command - frontend-ci: - build: - context: . - dockerfile: frontend/Dockerfile - # https://hub.docker.com/_/postgres/ db: image: postgres:12.7 From 3bf7e4240589bad4982ace2bcecf1c0078fa70b2 Mon Sep 17 00:00:00 2001 From: Sven Marnach Date: Thu, 21 Dec 2023 15:44:11 +0100 Subject: [PATCH 3/3] bug-1871345: Install ripgrep inside the dev container. --- .devcontainer/Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index d6f2552b6..67951d3b5 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,6 +2,10 @@ FROM mcr.microsoft.com/devcontainers/python:3.11-bullseye@sha256:105bf6a63ab0252 WORKDIR /app +# Install Debian packages +RUN apt-get update && \ + apt-get install -y ripgrep + # Install Python dependencies COPY requirements.txt /app/ RUN pip install -U 'pip>=20' && \