-
-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create prod Dockerimage from alpine base image #222
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM python:3.11-alpine | ||
|
||
# set work directory | ||
WORKDIR /usr/src/app | ||
|
||
# set environment variables | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# install system dependencies | ||
RUN apk update && \ | ||
apk add --no-cache netcat-openbsd gcc postgresql graphviz musl-dev libffi-dev | ||
|
||
# install dependencies | ||
RUN pip install --no-cache-dir pip~=21.3.1 | ||
COPY ./requirements.txt . | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# # copy entrypoint.sh | ||
ENTRYPOINT ["./entrypoint.sh"] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
black~=22.3.0 | ||
cryptography~=37.0.2 | ||
Django~=4.0.1 | ||
django-extensions~=3.1.5 | ||
django-linear-migrations~=2.12.0 | ||
django-phonenumber-field[phonenumbers]~=6.3.0 | ||
django-timezone-field==5.0 | ||
djangorestframework~=3.13.1 | ||
drf-jwt~=1.19.2 | ||
drf-spectacular==0.22.1 | ||
psycopg2-binary~=2.9.3 | ||
pydot~=1.4.2 | ||
pytz==2022.1 | ||
tzdata==2022.1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
version: '3.8' | ||
|
||
services: | ||
db: | ||
image: postgres:13.0-alpine | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data/ | ||
environment: | ||
- POSTGRES_USER=people_depot | ||
- POSTGRES_PASSWORD=people_depot | ||
- POSTGRES_DB=people_depot_dev | ||
container_name: people_depot_db | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting the container name might not be a good idea. I'll have to look up the reasoning for this again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yeah, the container_name allows you to refer to it by name in a |
||
web: | ||
build: ./app/prod | ||
command: python manage.py runserver 0.0.0.0:8000 | ||
volumes: | ||
- ./app/:/usr/src/app/ | ||
ports: | ||
- 8000:8000 | ||
env_file: | ||
- ./.env.dev | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe have a separate .env or .env.prod file for production |
||
container_name: people_depot_app_prod | ||
depends_on: | ||
- db | ||
volumes: | ||
postgres_data: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ services: | |
- 8000:8000 | ||
env_file: | ||
- ./.env.dev | ||
container_name: people_depot_dev | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same reasoning as above for not setting the container name. We're mainly referring to containers using |
||
depends_on: | ||
- db | ||
db: | ||
|
@@ -20,6 +21,7 @@ services: | |
- POSTGRES_USER=people_depot | ||
- POSTGRES_PASSWORD=people_depot | ||
- POSTGRES_DB=people_depot_dev | ||
|
||
container_name: people_depot_db_dev | ||
volumes: | ||
postgres_data: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove black, drf-spectacular, pydot, and maybe django-linear-migrations from the production build. I don't think there's any use for them outside development.