Skip to content
Snippets Groups Projects
Commit 6be53c54 authored by Moul's avatar Moul
Browse files

[ci] #388: Add poetry and pip kinds of containers builds

- Pip for direct consumers like DeathReaper
- Poetry for developers
parent fabe55c6
No related branches found
No related tags found
No related merge requests found
Pipeline #11685 failed
......@@ -83,20 +83,28 @@ tests-3.9:
services:
- docker:dind
script:
- docker pull $CI_REGISTRY_IMAGE:$IMAGE_TAG || true
- docker build --cache-from $CI_REGISTRY_IMAGE:$IMAGE_TAG --pull -t "$CI_REGISTRY_IMAGE:$IMAGE_TAG" -f release/container-pip .
- docker pull $CI_REGISTRY_IMAGE/$KIND:$IMAGE_TAG || true
- docker build --cache-from $CI_REGISTRY_IMAGE/$KIND:$IMAGE_TAG --pull -t "$CI_REGISTRY_IMAGE/$KIND:$IMAGE_TAG" -f release/container-$KIND .
- docker login -u "$CI_REGISTRY_USER" -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:
- docker tag "$CI_REGISTRY_IMAGE/$KIND:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$KIND:$IMAGE_TAG"
- docker push "$CI_REGISTRY_IMAGE/$KIND:$IMAGE_TAG"
- docker tag "$CI_REGISTRY_IMAGE/$KIND:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$KIND:latest"
- docker push "$CI_REGISTRY_IMAGE/$KIND:latest"
container:poetry:
extends: .container
variables:
KIND: "poetry"
IMAGE_TAG: "dev"
# rules:
# - when: manual
container:pip:
extends: .container
variables:
KIND: "pip"
IMAGE_TAG: "dev"
pypi_test:
stage: package
rules:
......
......@@ -2,7 +2,7 @@
# Build Stage
# ------------------------------------------------------------------------------
ARG PYTHON_VERS=3.9
FROM registry.duniter.org/docker/python3/poetry/${PYTHON_VERS}:latest as build
FROM python:${PYTHON_VERS}-slim-buster AS build
WORKDIR /silkaj
......@@ -15,7 +15,7 @@ RUN pip install .
# ------------------------------------------------------------------------------
# Final Stage
# ------------------------------------------------------------------------------
FROM registry.duniter.org/docker/python3/poetry/${PYTHON_VERS}:latest
FROM python:${PYTHON_VERS}-slim-buster
ARG PYTHON_VERS=3.9
# Create silkaj group and user
......@@ -26,6 +26,11 @@ RUN groupadd -g 1111 silkaj && \
COPY --from=build /usr/local/bin/silkaj /usr/local/bin/silkaj
COPY --from=build /usr/local/lib/python${PYTHON_VERS}/site-packages/ /usr/local/lib/python${PYTHON_VERS}/site-packages/
# Install libsodium
RUN apt update && \
apt install --yes libsodium23 && \
rm -rf /var/lib/apt/lists
# Use silkaj user
USER silkaj
WORKDIR /usr/local/lib/python${PYTHON_VERS}/site-packages/silkaj
......
# ------------------------------------------------------------------------------
# Build Stage
# ------------------------------------------------------------------------------
ARG PYTHON_VERS=3.9
FROM registry.duniter.org/docker/python3/poetry/${PYTHON_VERS}:latest AS build
WORKDIR /silkaj
# Copy source tree
COPY ./ ./
# Install Silkaj
RUN poetry install --no-dev
# ------------------------------------------------------------------------------
# Final Stage
# ------------------------------------------------------------------------------
FROM registry.duniter.org/docker/python3/poetry/${PYTHON_VERS}:latest
ARG PYTHON_VERS=3.9
# Create silkaj group and user
RUN groupadd -g 1111 silkaj && \
useradd -d /silkaj -g silkaj -u 1111 silkaj
# Copy the build artifact from the build stage
COPY --from=build --chown=silkaj:silkaj /silkaj /silkaj
COPY --from=build --chown=silkaj:silkaj /root/.cache/pypoetry/virtualenvs /silkaj/.cache/pypoetry/virtualenvs
# Install git
RUN apt update && \
apt install --yes git && \
rm -rf /var/lib/apt/lists
# 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
# Use silkaj user
USER silkaj
WORKDIR /silkaj
CMD ["/usr/bin/silkaj"]
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