-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
118 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# list of files to exclude from docker build | ||
.git | ||
.cache | ||
db.sqlite3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
DEBUG=on | ||
SECRET_KEY=this_should_be_a super_secret_key | ||
DATABASE_URL=sqlite:////db.sqlite3 | ||
ALLOWED_HOSTS='["example.host.com"]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
__pycache__ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# https://pipenv.pypa.io/en/latest/basics/#pipenv-and-docker-containers | ||
FROM docker.io/python:3.10 AS base | ||
|
||
RUN apt update && \ | ||
apt install -y python3-dev libpq-dev | ||
|
||
|
||
######################################################### | ||
# Builder | ||
######################################################### | ||
FROM base AS builder | ||
|
||
RUN pip install --user pipenv | ||
|
||
# Tell pipenv to create venv in the current directory | ||
ENV PIPENV_VENV_IN_PROJECT=1 | ||
|
||
ADD Pipfile.lock Pipfile /usr/src/ | ||
|
||
WORKDIR /usr/src | ||
|
||
|
||
# NOTE: If you install binary packages required for a python module, you need | ||
# to install them again in the runtime. For example, if you need to install pycurl | ||
# you need to have pycurl build dependencies libcurl4-gnutls-dev and libcurl3-gnutls | ||
# In the runtime container you need only libcurl3-gnutls | ||
|
||
# RUN apt install -y libcurl3-gnutls libcurl4-gnutls-dev | ||
|
||
RUN /root/.local/bin/pipenv sync | ||
|
||
RUN /usr/src/.venv/bin/python -c "import django; print(django.__version__)" | ||
|
||
|
||
|
||
######################################################### | ||
# Runtime | ||
######################################################### | ||
FROM base AS runtime | ||
|
||
RUN mkdir -v /usr/src/venv | ||
|
||
COPY --from=builder /usr/src/.venv/ /usr/src/.venv/ | ||
COPY . /app | ||
|
||
RUN /usr/src/.venv/bin/python -c "import django; print(django.__version__)" | ||
ENV PATH="/usr/src/.venv/bin/:${PATH}" | ||
|
||
WORKDIR /app | ||
|
||
RUN STATIC_ROOT=/app/static SECRET_KEY=secret_is_irelevent_here DATABASE_URL=sqlite:////dunmmy_db.sqlite3 python manage.py collectstatic --noinput | ||
|
||
CMD ["gunicorn", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "scorer.asgi:application", "-b", "0.0.0.0:8000"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
|
||
Start like: `gunicorn scorer.asgi:application -k uvicorn.workers.UvicornWorker` | ||
# Getting Started | ||
|
||
or `uvicorn scorer.asgi:application --reload` | ||
Create virtual env and install dependencies: `pipenv install` | ||
|
||
Start the dev server: | ||
- `gunicorn -w 4 -k uvicorn.workers.UvicornWorker scorer.asgi:application` | ||
- or `uvicorn scorer.asgi:application --reload` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: '3' | ||
|
||
services: | ||
scorer: | ||
build: . | ||
restart: unless-stopped | ||
env_file: .env | ||
|
||
volumes: | ||
- ./db.sqlite3:/db.sqlite3 | ||
|
||
ports: | ||
- 80:8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters