Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug-1871345: Dev container improvements #2861

Merged
merged 3 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, i was missing this


# Install Python dependencies
COPY requirements.txt /app/
RUN pip install -U 'pip>=20' && \
Expand Down
3 changes: 1 addition & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"name": "Tecken",
"dockerComposeFile": [
"../docker-compose.yml",
"docker-compose.yml"
"../docker-compose.yml"
],
"service": "devcontainer",
"runServices": [
Expand Down
19 changes: 0 additions & 19 deletions .devcontainer/docker-compose.yml

This file was deleted.

13 changes: 3 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
47 changes: 27 additions & 20 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,9 +19,6 @@ services:
web:
extends:
service: base
depends_on:
- db
- redis-cache
ports:
- "${EXPOSE_TECKEN_PORT:-8000}:8000"
links:
Expand All @@ -33,7 +33,7 @@ services:
command: ["web", "--dev"]

# Container specifically for running tests.
test:
test-ci:
extends:
service: base
env_file:
Expand All @@ -43,19 +43,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:
Expand All @@ -68,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:
Expand All @@ -81,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
Expand Down