feat: Build docker container for release

!1
This commit is contained in:
2024-05-13 21:02:41 +09:30
parent db5d7e18ad
commit b3b12638ad
4 changed files with 81 additions and 2 deletions

12
.dockerignore Normal file
View File

@ -0,0 +1,12 @@
.git
.git*
website-template/
gitlab-ci/
venv/
docs/
**/*.sqlite3
**/static/
__pycache__
**__pycache__
**.pyc
** .pytest*

View File

@ -4,8 +4,19 @@ variables:
MY_PROJECT_ID: "57560288"
# GIT_SYNC_URL: "https://$GITHUB_USERNAME_ROBOT:$GITHUB_TOKEN_ROBOT@github.com/NoFussComputing/.git"
# Docker Build / Publish
DOCKER_IMAGE_BUILD_TARGET_PLATFORMS: "linux/amd64,linux/arm64"
DOCKER_IMAGE_BUILD_NAME: django-template
DOCKER_IMAGE_BUILD_REGISTRY: $CI_REGISTRY_IMAGE
DOCKER_IMAGE_BUILD_TAG: $CI_COMMIT_SHA
# Docker Publish
DOCKER_IMAGE_PUBLISH_NAME: django-template
DOCKER_IMAGE_PUBLISH_REGISTRY: docker.io/nofusscomputing
DOCKER_IMAGE_PUBLISH_URL: https://hub.docker.com/r/nofusscomputing/$DOCKER_IMAGE_PUBLISH_NAME
# Docs NFC
PAGES_ENVIRONMENT_PATH: projects/itsm/
PAGES_ENVIRONMENT_PATH: projects/django-template/
# RELEASE_ADDITIONAL_ACTIONS_BUMP: ./.gitlab/additional_actions_bump.sh
@ -18,3 +29,25 @@ include:
file:
- .gitlab-ci_common.yaml
- template/automagic.gitlab-ci.yaml
Website.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/infrastructure/website
environment:
url: https://nofusscomputing.com/$PAGES_ENVIRONMENT_PATH
name: Documentation
rules:
- if: # condition_dev_branch_push
$CI_COMMIT_BRANCH == "development" &&
$CI_PIPELINE_SOURCE == "push"
exists:
- '{docs/**,pages/**}/*.md'
changes:
paths:
- '{docs/**,pages/**}/*.md'
compare_to: 'master'
when: always
- when: never

View File

@ -19,7 +19,7 @@ To setup the django test server run the following
``` bash
cd itsm
cd app
python manage.py runserver 8002
@ -43,3 +43,16 @@ test can be run by running the following:
1. `pytest --cov --cov-report html --cov=./`
## Docker Container
``` bash
cd app
docker build . --tag django-app:dev
docker run -d --rm -v ${PWD}/db.sqlite3:/app/db.sqlite3 -p 8002:8000 --name app django-app:dev
```

21
dockerfile Normal file
View File

@ -0,0 +1,21 @@
FROM python:3.11-alpine3.19
COPY requirements.txt requirements.txt
COPY requirements_test.txt requirements_test.txt
COPY ./app/. app
RUN pip install --no-cache-dir -r requirements.txt; \
python /app/manage.py collectstatic --noinput
WORKDIR /app
EXPOSE 8000
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]