Skip to content

Commit 91f7f90

Browse files
committed
Added devcontainer definition
1 parent 2f54a3b commit 91f7f90

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed

.devcontainer/.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
POSTGRES_USER=postgres
2+
POSTGRES_PASSWORD=postgres
3+
POSTGRES_DB=postgres
4+
POSTGRES_HOST=localhost

.devcontainer/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM mcr.microsoft.com/devcontainers/anaconda:0-3
2+
3+
# Copy environment.yml (if found) to a temp location so we update the environment. Also
4+
# copy "noop.txt" so the COPY instruction does not fail if no environment.yml exists.
5+
COPY environment.yml* .devcontainer/noop.txt /tmp/conda-tmp/
6+
7+
RUN if [ -f "/tmp/conda-tmp/environment.yml" ]; then umask 0002 && /opt/conda/bin/conda env update -n base -f /tmp/conda-tmp/environment.yml; fi \
8+
&& rm -rf /tmp/conda-tmp
9+
10+
# [Optional] Uncomment this section to install additional OS packages.
11+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
12+
# && apt-get -y install --no-install-recommends <your-package-list-here>

.devcontainer/devcontainer.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/anaconda-postgres
3+
{
4+
"name": "Anaconda (Python 3) & PostgreSQL",
5+
"dockerComposeFile": "docker-compose.yml",
6+
"service": "app",
7+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
8+
"features": {
9+
"ghcr.io/devcontainers/features/azure-cli:1": {},
10+
"ghcr.io/devcontainers/features/github-cli:1": {}
11+
},
12+
13+
// Features to add to the dev container. More info: https://containers.dev/features.
14+
// "features": {},
15+
16+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
17+
"forwardPorts": [5432, 3000, 5000]
18+
19+
// Use 'postCreateCommand' to run commands after the container is created.
20+
// "postCreateCommand": "python --version",
21+
22+
// Configure tool-specific properties.
23+
// "customizations": {},
24+
25+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
26+
// "remoteUser": "root"
27+
}

.devcontainer/docker-compose.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
build:
6+
context: ..
7+
dockerfile: .devcontainer/Dockerfile
8+
env_file:
9+
- .env
10+
11+
volumes:
12+
- ../..:/workspaces:cached
13+
14+
# Overrides default command so things don't shut down after the process ends.
15+
command: sleep infinity
16+
17+
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
18+
network_mode: service:db
19+
20+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
21+
# (Adding the "ports" property to this file will not forward from a Codespace.)
22+
23+
db:
24+
image: postgres:latest
25+
restart: unless-stopped
26+
volumes:
27+
- postgres-data:/var/lib/postgresql/data
28+
env_file:
29+
- .env
30+
31+
# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
32+
# (Adding the "ports" property to this file will not forward from a Codespace.)
33+
34+
volumes:
35+
postgres-data:

.devcontainer/noop.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This file copied into the container along with environment.yml* from the parent
2+
folder. This file is included to prevents the Dockerfile COPY instruction from
3+
failing if no environment.yml is found.

0 commit comments

Comments
 (0)