Skip to content

Commit

Permalink
Make devcontainer work for all services
Browse files Browse the repository at this point in the history
  • Loading branch information
pamelafox committed Nov 25, 2024
1 parent 96c6048 commit d7167eb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
4 changes: 4 additions & 0 deletions .devcontainer/tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
ARG IMAGE=bullseye
FROM mcr.microsoft.com/devcontainers/${IMAGE}

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends postgresql-client \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
5 changes: 3 additions & 2 deletions .devcontainer/tests/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// For format details, see https://aka.ms/devcontainer.json.
{
"name": "flask-admin tests (Postgres + Azurite)",
"name": "flask-admin tests (Postgres + Azurite + Mongo)",
"dockerComposeFile": "docker-compose.yaml",
"service": "app",
"workspaceFolder": "/workspace",
Expand All @@ -11,5 +11,6 @@
"5432": {"label": "PostgreSQL port", "onAutoForward": "silent"}
},
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
"remoteUser": "vscode",
"postAttachCommand": "psql -U postgres -h localhost -c 'CREATE EXTENSION IF NOT EXISTS hstore;' flask_admin_test && pip install -e \".[all]\" && pip install --use-pep517 -r requirements/dev.txt"
}
26 changes: 13 additions & 13 deletions .devcontainer/tests/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,32 @@ services:

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: host
environment:
AZURE_STORAGE_CONNECTION_STRING: DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;

postgres:
# Docker Hub image
image: postgis/postgis:16-3.4 # postgres with postgis installed
image: postgis/postgis:16-3.4
restart: unless-stopped
# Provide the password for postgres
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: flask_admin_test
volumes:
- postgres-data:/var/lib/postgresql/data

azureblob:
network_mode: service:app

azurite:
container_name: azurite
image: mcr.microsoft.com/azure-storage/azurite:latest
restart: unless-stopped
volumes:
- azureblob-data:/data
- azurite-data:/data
network_mode: service:app

# Add "forwardPorts": ["10000", "10001"] to **devcontainer.json** to forward Azurite locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
mongo:
image: mongo:5.0.14-focal
restart: unless-stopped
network_mode: service:app

volumes:
postgres-data:
azureblob-data:

azurite-data:

0 comments on commit d7167eb

Please sign in to comment.