Skip to content
Snippets Groups Projects
Commit cba495b6 authored by Stefan Hynek's avatar Stefan Hynek :drooling_face:
Browse files

Merge branch '1-prepare-dockerfile-and-ci-for-testing-image-build' into 'main'

Resolve "prepare Dockerfile and CI for testing image build"

Closes #1

See merge request !1
parents 19036498 a0032db7
No related branches found
No related tags found
1 merge request!1Resolve "prepare Dockerfile and CI for testing image build"
Pipeline #246204 passed
---
workflow:
rules:
- if: $CI_MERGE_REQUEST_IID
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_TAG
stages:
- test
- build
lint dockerfile:
stage: test
image: hadolint/hadolint:latest-debian
before_script:
- mkdir -p reports
script:
- hadolint --format gitlab_codeclimate Dockerfile > reports/hadolint-$(md5sum Dockerfile | cut -d" " -f1).json
artifacts:
name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG"
when: always
reports:
codequality:
- "reports/*"
paths:
- "reports/*"
rules:
- if: $CI_MERGE_REQUEST_IID
changes:
- Dockerfile
build container image:
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$(echo -n ${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD} | base64 | tr -d '\n')\"},\"$harbor_registry\":{\"auth\":\"$HARBOR_ROBOT_TOKEN64\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor
--context $CI_PROJECT_DIR
--dockerfile $CI_PROJECT_DIR/Dockerfile
--build-arg build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
--build-arg vcs_ref=${CI_COMMIT_SHORT_SHA}
--build-arg version=${CI_COMMIT_SHORT_SHA}
--destination $CI_REGISTRY_IMAGE/repdav:$CI_COMMIT_SHORT_SHA
--destination $harbor_registry/$harbor_repo/repdav:$CI_COMMIT_SHORT_SHA
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
# syntax=docker/dockerfile:1
FROM python:3.8
LABEL \
org.label-schema.dockerfile="/Dockerfile" \
org.label-schema.license="AGPL-3.0-or-later" \
org.label-schema.maintainer="Stefan Hynek" \
org.label-schema.name="Textgrid Repository WebDAV Server" \
org.label-schema.schema-version="1.0" \
org.label-schema.url="https://gitlab.gwdg.de/dariah-de/textgridrep/repdav" \
org.label-schema.vcs-url="https://gitlab.gwdg.de/dariah-de/textgridrep/repdav" \
org.label-schema.vendor="SUB/FE"
RUN useradd --create-home repdav
USER repdav
COPY --chown=repdav requirements.txt /
RUN pip install \
--no-cache-dir \
--requirement requirements.txt \
--user
WORKDIR /app
COPY --chown=repdav src/ .
COPY requirements.txt .
RUN pip install -r requirements.txt
ARG build_date
ARG vcs_ref
ARG version
LABEL \
org.label-schema.build-date="${build_date}" \
org.label-schema.vcs-ref="${vcs_ref}" \
org.label-schema.version="${version}"
CMD ["python", "main.py"]
COPY Dockerfile /
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment