Skip to content

Commit 3d7774a

Browse files
committed
Improve development setup
1 parent 8d420ef commit 3d7774a

File tree

5 files changed

+38
-8
lines changed

5 files changed

+38
-8
lines changed

.devcontainer/Dockerfile

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
FROM mcr.microsoft.com/devcontainers/python:3.13
22

3-
# Install dependency to make bash completion work with invoke
4-
RUN apt-get update && \
5-
export DEBIAN_FRONTEND=noninteractive && \
6-
apt-get install -y bash-completion && \
7-
apt-get clean && \
8-
rm -rf /var/lib/apt/lists/*
3+
USER root
4+
5+
# Install system dependencies
6+
# - bash-completion for shell completions of invoke
7+
# - gettext for Django translations
8+
# - postgresql-common for the apt.postgresql.org.sh script
9+
# - postgresql-client-17 for a current version of psql
10+
RUN sudo apt-get update \
11+
&& export DEBIAN_FRONTEND=noninteractive \
12+
&& apt-get install -y --no-install-recommends \
13+
bash-completion \
14+
gettext \
15+
postgresql-common \
16+
&& /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y \
17+
&& apt-get install -y --no-install-recommends \
18+
postgresql-client-17 \
19+
&& apt-get clean \
20+
&& rm -rf /var/lib/apt/lists/*
921

1022
USER vscode
1123

adit/settings/base.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@
1616
import environ
1717
from pydicom import config as pydicom_config
1818

19+
# During development and calling `manage.py` from the host most environment variables are
20+
# set using the `.env` file (see `manage.py`). But some variables are only used in the Docker
21+
# compose setup, so we need to provide defaults here.
1922
env = environ.Env()
23+
llamacpp_dev_port = env.int("LLAMACPP_DEV_PORT")
24+
postgres_dev_port = env.int("POSTGRES_DEV_PORT")
25+
env = environ.Env(
26+
DATABASE_URL=(str, f"postgres://postgres:postgres@localhost:{postgres_dev_port}/postgres"),
27+
DBBACKUP_STORAGE_LOCATION=(str, "/temp/backups-radis"),
28+
LLAMACPP_URL=(str, f"http://localhost:{llamacpp_dev_port}"),
29+
)
2030

2131
# The base directory of the project (the root of the repository)
2232
BASE_DIR = Path(__file__).resolve(strict=True).parent.parent.parent

docker-compose.dev.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ services:
6464
postgres:
6565
environment:
6666
POSTGRES_PASSWORD: postgres
67+
ports:
68+
- "${POSTGRES_DEV_PORT:-5432}:5432"
6769

6870
volumes:
6971
vscode-server:

example.env

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
# Use 'development' for local development, and 'production' in production.
33
ENVIRONMENT=development
44

5-
# The host port that will be mapped to the development server (only used in development).
5+
# Ports that will be mapped to the host during development.
6+
POSTGRES_DEV_PORT=5432
7+
LLAMACPP_DEV_PORT=8080
68
WEB_DEV_PORT=8000
79

8-
# The host ports that will be mapped to the production server (only used in production).
10+
# Ports that will be mapped to the host during production.
911
WEB_HTTP_PORT=80
1012
WEB_HTTPS_PORT=443
1113

manage.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
import os
55
import sys
66

7+
from dotenv import load_dotenv
8+
9+
load_dotenv()
10+
711

812
def initialize_debugger():
913
"""Enable remote debugging."""

0 commit comments

Comments
 (0)