diff --git a/Dockerfile b/Dockerfile index 26b14fea0df87ead30a77f876de29ecef2dff863..8517f74ad6940c5d0d98205dbba3b0f9ab245d3d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,36 @@ -FROM registry.duniter.org/docker/python3/poetry/3.9:latest +# ------------------------------------------------------------------------------ +# Build Stage +# ------------------------------------------------------------------------------ +FROM registry.duniter.org/docker/python3/poetry/3.9:latest as build + +WORKDIR /silkaj -RUN ls && ls silkaj +# Copy source tree +COPY ./ ./ # Install Silkaj RUN poetry install +# ------------------------------------------------------------------------------ +# Final Stage +# ------------------------------------------------------------------------------ +FROM registry.duniter.org/docker/python3/poetry/3.9:latest + +# Create silkaj group and user +RUN addgroup -S -g 1111 silkaj && \ + adduser -SD -h /silkaj -G silkaj -u 1111 silkaj + +# Copy the build artifact from the build stage +COPY --from=build --chown=silkaj:silkaj /silkaj /silkaj + # 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 + chmod +x /usr/bin/silkaj && \ + chown silkaj: /usr/bin/silkaj + +# Use silkaj user +USER silkaj +WORKDIR /silkaj CMD ["/usr/bin/silkaj"]