Skip to content

Commit 0120fc4

Browse files
Update django example
Deps, ignore, dockerfile/compose
1 parent eab841e commit 0120fc4

File tree

6 files changed

+69
-10
lines changed

6 files changed

+69
-10
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# ETC
22
django/composeexample/
33
django/data/
4-
django/manage.py
54
*.sqlite
65
!*.example
76
*.pem

django/.dockerignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
**/__pycache__
2+
**/.classpath
3+
**/.dockerignore
4+
**/.DS_Store
5+
**/.editorconfig
6+
**/.env
7+
**/.git
8+
**/.github
9+
**/.gitignore
10+
**/.project
11+
**/.settings
12+
**/.toolstarget
13+
**/.vs
14+
**/.vscode
15+
**/*.*proj.user
16+
**/*.dbmdl
17+
**/*.jfm
18+
**/*.py#
19+
**/*.py~
20+
**/*.pyc
21+
**/azds.yaml
22+
**/bin
23+
**/charts
24+
**/compose*
25+
**/csv
26+
**/django
27+
**/docker-compose*
28+
**/Dockerfile*
29+
**/img
30+
**/node_modules
31+
**/npm-debug.log
32+
**/obj
33+
**/README.md
34+
**/secrets.dev.yaml
35+
**/terraform
36+
**/values.dev.yaml

django/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# syntax=docker/dockerfile:1
2-
FROM python:3
2+
FROM python:3.10.9-slim-bullseye
33
ENV PYTHONDONTWRITEBYTECODE=1
44
ENV PYTHONUNBUFFERED=1
5-
WORKDIR /code
6-
COPY requirements.txt /code/
5+
WORKDIR /app
6+
COPY requirements.txt .
77
RUN pip install -r requirements.txt
8-
COPY . /code/
8+
COPY . .

django/compose.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ version: "3.9"
33

44
services:
55
db:
6+
platform: linux/arm64/v8
67
image: postgres
78
volumes:
89
- ./data/db:/var/lib/postgresql/data
@@ -11,12 +12,13 @@ services:
1112
- POSTGRES_USER=postgres
1213
- POSTGRES_PASSWORD=postgres
1314
web:
15+
platform: linux/arm64/v8
1416
build: .
15-
command: python manage.py runserver 0.0.0.0:8000
17+
command: python manage.py runserver 0.0.0.0:${PORT:-8000}
1618
volumes:
17-
- .:/code
19+
- .:/app
1820
ports:
19-
- "8000:8000"
21+
- ${PORT:-8000}:${PORT:-8000}
2022
environment:
2123
- POSTGRES_NAME=postgres
2224
- POSTGRES_USER=postgres

django/manage.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
3+
import os
4+
import sys
5+
6+
7+
def main():
8+
"""Run administrative tasks."""
9+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "composeexample.settings")
10+
try:
11+
from django.core.management import execute_from_command_line
12+
except ImportError as exc:
13+
raise ImportError(
14+
"Couldn't import Django. Are you sure it's installed and "
15+
"available on your PYTHONPATH environment variable? Did you "
16+
"forget to activate a virtual environment?"
17+
) from exc
18+
execute_from_command_line(sys.argv)
19+
20+
21+
if __name__ == "__main__":
22+
main()

django/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Django>=3.0,<4.0
2-
psycopg2>=2.8
1+
django==4.1.7 ; python_full_version >= "3.10.9" and python_full_version < "4.0.0"
2+
psycopg2-binary==2.9.5 ; python_full_version >= "3.10.9" and python_full_version < "4.0.0"

0 commit comments

Comments
 (0)