Skip to content
Snippets Groups Projects
Verified Commit 827a6480 authored by Daniel Göbel's avatar Daniel Göbel
Browse files

Publish docker container in gitlab container registry

#12
parent 24fab58d
No related branches found
No related tags found
No related merge requests found
...@@ -33,7 +33,7 @@ default: ...@@ -33,7 +33,7 @@ default:
stages: # List of stages for jobs, and their order of execution stages: # List of stages for jobs, and their order of execution
# - build # - build
- test - test
# - deploy - deploy
integration-test-job: # Runs integration tests with the database integration-test-job: # Runs integration tests with the database
stage: test stage: test
...@@ -114,8 +114,36 @@ lint-test-job: # Runs linters checks on code ...@@ -114,8 +114,36 @@ lint-test-job: # Runs linters checks on code
script: script:
- ./scripts/lint.sh - ./scripts/lint.sh
#deploy-job: # This job runs in the deploy stage. build-publish-dev-docker-container-job:
# stage: deploy # It only runs when *both* jobs in the test stage complete successfully. stage: deploy
# script: image:
# - echo "Deploying application..." name: gcr.io/kaniko-project/executor:v1.9.1-debug
# - echo "Application successfully deployed." entrypoint: [""]
only:
refs:
- development
before_script:
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"},\"$CI_DEPENDENCY_PROXY_SERVER\":{\"auth\":\"$(printf "%s:%s" ${CI_DEPENDENCY_PROXY_USER} "${CI_DEPENDENCY_PROXY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
script:
- /kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
--destination "${CI_REGISTRY_IMAGE}:dev-${CI_COMMIT_SHA}"
build-publish-docker-container-job:
stage: deploy
image:
name: gcr.io/kaniko-project/executor:v1.9.1-debug
entrypoint: [""]
only:
- tags
before_script:
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"},\"$CI_DEPENDENCY_PROXY_SERVER\":{\"auth\":\"$(printf "%s:%s" ${CI_DEPENDENCY_PROXY_USER} "${CI_DEPENDENCY_PROXY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
script:
- /kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
--destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}"
--destination "${CI_REGISTRY_IMAGE}:$(echo ${CI_COMMIT_TAG} | cut -d'.' -f1-2)"
--destination "${CI_REGISTRY_IMAGE}:$(echo ${CI_COMMIT_TAG} | cut -d'.' -f1)"
--destination "${CI_REGISTRY_IMAGE}:latest"
FROM python:3.10-slim FROM python:3.10-slim
WORKDIR /code EXPOSE 8000
ENV PYTHONPATH=/code
EXPOSE 80
# dumb-init forwards the kill signal to the python process # dumb-init forwards the kill signal to the python process
RUN apt-get update && apt-get -y install dumb-init curl RUN apt-get update && apt-get -y install dumb-init curl
ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENTRYPOINT ["/usr/bin/dumb-init", "--"]
HEALTHCHECK --interval=35s --timeout=4s CMD curl -f http://localhost/health || exit 1 HEALTHCHECK --interval=35s --timeout=4s CMD curl -f http://localhost:8000/health || exit 1
COPY requirements.txt ./requirements.txt RUN useradd -m worker
USER worker
WORKDIR /home/worker/code
ENV PYTHONPATH=/home/worker/code
ENV PATH="/home/worker/.local/bin:${PATH}"
RUN pip install --no-cache-dir --upgrade -r requirements.txt COPY --chown=worker:worker requirements.txt ./requirements.txt
COPY . . RUN pip install --user --no-cache-dir --upgrade -r requirements.txt
COPY --chown=worker:worker . .
CMD ["./start_service.sh"] CMD ["./start_service.sh"]
...@@ -6,4 +6,4 @@ python app/check_ceph_connection.py ...@@ -6,4 +6,4 @@ python app/check_ceph_connection.py
python app/check_database_connection.py python app/check_database_connection.py
# Start webserver # Start webserver
uvicorn app.main:app --host 0.0.0.0 --port 80 uvicorn app.main:app --host 0.0.0.0 --port 8000
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment