Dockerfile & .gitlab-ci.yaml

This commit is contained in:
Oscar Krause 2022-12-16 13:55:17 +01:00
parent cbe213ace3
commit 1a697a9111
2 changed files with 42 additions and 0 deletions

26
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,26 @@
cache:
key: one-key-to-rule-them-all
build:
image: docker:dind
interruptible: true
stage: build
rules:
- if: $CI_COMMIT_BRANCH
tags: [ docker ]
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build . --tag ${CI_REGISTRY}/${CI_PROJECT_PATH}/${CI_BUILD_REF_NAME}:${CI_BUILD_REF}
- docker push ${CI_REGISTRY}/${CI_PROJECT_PATH}/${CI_BUILD_REF_NAME}:${CI_BUILD_REF}
test:
stage: test
script:
- echo "Nothing to do ..."
deploy:
stage: deploy
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- echo "Nothing to do ..."

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM python:3.10-alpine
COPY requirements.txt /tmp/requirements.txt
RUN apk update \
&& apk add --no-cache --virtual build-deps gcc g++ python3-dev musl-dev \
&& apk add --no-cache postgresql postgresql-dev mariadb-connector-c-dev \
&& pip install --no-cache-dir --upgrade uvicorn \
&& pip install --no-cache-dir psycopg2==2.9.3 mysqlclient==2.1.1 pysqlite3==0.4.7 \
&& pip install --no-cache-dir -r /tmp/requirements.txt \
&& apk del build-deps
COPY app /app
HEALTHCHECK --start-period=30s --interval=10s --timeout=5s --retries=3 CMD curl --fail http://localhost/status || exit 1
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "443", "--app-dir", "/app", "--proxy-headers"]