File tree Expand file tree Collapse file tree 4 files changed +12
-7
lines changed
Expand file tree Collapse file tree 4 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 1111
1212 runs-on : ubuntu-latest
1313 env :
14- DJANGO_SECRET_KEY : for-testing-only
14+ DJANGO_SECRET_KEY_FILE : ${{ runner.temp }}/django_secret_key
1515 strategy :
1616 matrix :
1717 python-version : ['3.10']
3232 steps :
3333 - name : Write Docker-secrets-like file for CI
3434 run : |
35- mkdir -p /run/secrets && touch /run/secrets/django_secret_key
36- echo "for-testing-only" > /run/secrets/django_secret_key
35+ echo "for-testing-only" > $DJANGO_SECRET_KEY_FILE
3736
3837 - uses : actions/checkout@v5
3938
Original file line number Diff line number Diff line change @@ -20,4 +20,5 @@ WORKDIR /usr/src/app
2020RUN uv sync --locked
2121
2222# Collect static files
23- RUN --mount=type=secret,id=django_secret_key,required=true uv run python manage.py collectstatic --no-input
23+ RUN --mount=type=secret,id=django_secret_key,required=true \
24+ DJANGO_SECRET_KEY_FILE=/run/secrets/django_secret_key uv run python manage.py collectstatic --no-input
Original file line number Diff line number Diff line change 44# Build paths inside the project like this: BASE_DIR / 'subdir'.
55BASE_DIR = Path (__file__ ).resolve ().parent .parent
66
7- # Read the secret from the file that Docker injects
8- # (see https://docs.docker.com/reference/compose-file/build/#secrets)
9- _secret_key_file = open ("/run/secrets/django_secret_key" , "r" )
7+ # Get path to the file containing the secret (this is a Docker-specific method)
8+ _secret_key_file_path = os .getenv ("DJANGO_SECRET_KEY_FILE" )
9+ if not _secret_key_file_path :
10+ raise Exception ("DJANGO_SECRET_KEY_FILE must be a file path string" )
11+
12+ # Read the secret from the file
13+ _secret_key_file = open (_secret_key_file_path , "r" )
1014SECRET_KEY = _secret_key_file .read ()
1115_secret_key_file .close ()
1216
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ services:
4646 - django_secret_key
4747 environment :
4848 - PYTHONUNBUFFERED=0
49+ - DJANGO_SECRET_KEY_FILE=/run/secrets/django_secret_key
4950 - PROD_HOST_NAME
5051 - PROD_CSRF_ORIGIN
5152 - RP_ID
You can’t perform that action at this time.
0 commit comments