-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #217 from open-contracting/docker
Docker
- Loading branch information
Showing
29 changed files
with
514 additions
and
203 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,26 @@ | ||
# Dotfiles | ||
**/.* | ||
|
||
# Docker | ||
**/Dockerfile* | ||
|
||
# Requirements | ||
**/requirements.in | ||
**/requirements_dev.in | ||
**/requirements_dev.txt | ||
|
||
# Documentation | ||
docs | ||
LICENSE | ||
README.md | ||
README.rst | ||
|
||
# Configuration | ||
pyproject.toml | ||
|
||
# Testing | ||
**/tests | ||
pytest.ini | ||
|
||
# Generated files | ||
**/node_modules |
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
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,38 @@ | ||
name: Deploy | ||
on: | ||
workflow_run: | ||
workflows: ["CI"] | ||
branches: [main] | ||
types: | ||
- completed | ||
jobs: | ||
docker: | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
# https://github.com/docker/login-action#github-container-registry | ||
- uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
# https://github.com/docker/setup-buildx-action#usage | ||
- uses: docker/setup-buildx-action@v3 | ||
# https://github.com/docker/build-push-action#usage | ||
- uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
file: Dockerfile_django | ||
tags: | | ||
ghcr.io/${{ github.repository }}-django:latest | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
- uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
file: Dockerfile_static | ||
tags: | | ||
ghcr.io/${{ github.repository }}-static:latest | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
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
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
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
.coverage | ||
__pycache__ | ||
/media | ||
/static | ||
/venv | ||
docs/_build | ||
.hypothesis | ||
|
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
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 @@ | ||
3.10 | ||
3.11 |
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
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,43 @@ | ||
FROM python:3.11 as build-stage | ||
|
||
COPY requirements.txt /tmp/requirements.txt | ||
RUN pip install --no-cache-dir -r /tmp/requirements.txt | ||
|
||
WORKDIR /workdir | ||
|
||
COPY . . | ||
|
||
ENV DJANGO_ENV=production | ||
|
||
RUN python manage.py collectstatic --noinput -v2 | ||
|
||
FROM python:3.11 | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
gettext \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN groupadd -r runner && useradd --no-log-init -r -g runner runner | ||
|
||
# Must match the settings.DATABASES default value. | ||
RUN mkdir -p /data/db && chown -R runner:runner /data/db | ||
# Must match the settings.MEDIA_ROOT default value. | ||
RUN mkdir -p /data/media && chown -R runner:runner /data/media | ||
|
||
COPY requirements.txt /tmp/requirements.txt | ||
RUN pip install --no-cache-dir -r /tmp/requirements.txt | ||
|
||
WORKDIR /workdir | ||
USER runner:runner | ||
COPY --chown=runner:runner . . | ||
|
||
# Django needs a copy of the staticfiles.json manifest file. | ||
COPY --from=build-stage --chown=runner:runner /workdir/static/staticfiles.json /workdir/static/staticfiles.json | ||
|
||
ENV DJANGO_ENV=production | ||
ENV WEB_CONCURRENCY=2 | ||
|
||
RUN python manage.py compilemessages | ||
|
||
EXPOSE 8000 | ||
CMD ["gunicorn", "core.wsgi", "--bind", "0.0.0.0:8000", "--worker-tmp-dir", "/dev/shm", "--threads", "2", "--name", "cove"] |
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,17 @@ | ||
FROM python:3.11 as build-stage | ||
|
||
COPY requirements.txt /tmp/requirements.txt | ||
RUN pip install --no-cache-dir -r /tmp/requirements.txt | ||
|
||
WORKDIR /workdir | ||
COPY . . | ||
|
||
ENV DJANGO_ENV=production | ||
|
||
RUN python manage.py collectstatic --noinput -v2 | ||
|
||
FROM nginxinc/nginx-unprivileged:latest as production-stage | ||
USER root | ||
COPY --from=build-stage --chown=nginx:root /workdir/static /usr/share/nginx/html/static | ||
COPY --chown=nginx:root default.conf /etc/nginx/conf.d/default.conf | ||
USER nginx |
File renamed without changes.
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,16 @@ | ||
""" | ||
ASGI config for core project. | ||
It exposes the ASGI callable as a module-level variable named ``application``. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.asgi import get_asgi_application | ||
|
||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings") | ||
|
||
application = get_asgi_application() |
File renamed without changes.
Oops, something went wrong.