From c087d38ec49dfeae02580af24d059f3c73fc34b9 Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Sat, 3 Apr 2021 13:27:05 +0200 Subject: [PATCH] [ci] #388: Add image generation build automation Introduce Dockerfile based on latest Python available Install silkaj and make it available to the CLI Manual triggered job to generate the image Definition as an extensible job for future usages Rename stage --- .gitlab-ci.yml | 26 ++++++++++++++++++++++++-- Dockerfile | 12 ++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7a6c0f35..635a17af 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ stages: - checks - tests + - package - publish - coverage @@ -76,8 +77,29 @@ tests-3.9: variables: PYTHON_VERSION: "3.9" +.container: + stage: package + tags: [redshift] + services: + - docker:dind + script: + - docker login -u "gitlab-ci-token" -p "$CI_BUILD_TOKEN" $CI_REGISTRY + - docker build --pull -t "$CI_REGISTRY_IMAGE:$IMAGE_TAG" . + - docker login -u "gitlab-ci-token" -p "$CI_BUILD_TOKEN" $CI_REGISTRY + - docker tag "$CI_REGISTRY_IMAGE:$IMAGE_TAG" "$CI_REGISTRY_IMAGE:$IMAGE_TAG" + - docker push "$CI_REGISTRY_IMAGE:$IMAGE_TAG" + - docker tag "$CI_REGISTRY_IMAGE:$IMAGE_TAG" "$CI_REGISTRY_IMAGE:latest" + - docker push "$CI_REGISTRY_IMAGE:latest" + +container: + extends: .container + variables: + IMAGE_TAG: "dev" + rules: + - when: manual + pypi_test: - stage: publish + stage: package rules: - if: $CI_COMMIT_TAG when: manual @@ -86,7 +108,7 @@ pypi_test: - poetry publish --build --username $PYPI_TEST_LOGIN --password $PYPI_TEST_PASSWORD --repository pypi_test pypi: - stage: publish + stage: package rules: - if: $CI_COMMIT_TAG when: manual diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..744ef940 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM registry.duniter.org/docker/python3/poetry/3.9:latest + +# Install Silkaj +RUN cd silkaj && poetry install + +# Set up alias to directly get silkaj command +# https://stackoverflow.com/a/3638886 +RUN printf '#!/bin/bash\npoetry run silkaj "$@"' > /usr/bin/silkaj && \ + chmod +x /usr/bin/silkaj + +WORKDIR /silkaj +CMD ["/usr/bin/silkaj"] -- GitLab