73 lines
2.0 KiB

FROM python:3.9 as base
ENV DEBIAN_FRONTEND noninteractive
ENV TERM=xterm-256color
RUN python3 -m pip install --upgrade pip
# needs wwwsudois as a dependency for the shared jinja
# need to make this nicer
# used to force running this step to pull new versions
# but it is also installed in the final stage and gets run if anything changed
ENV wwwsudois_version "v1.9.14"
RUN curl -fsSL | apt-key add - && \
echo "deb /" | tee /etc/apt/sources.list.d/sudois.list && \
apt-get update && \
apt-get install wwwsudois && \
apt-get clean
FROM base as builder
ENV PATH "$PATH:/home/builder/.local/bin"
WORKDIR /builder
RUN useradd -m -u ${BUILD_UID} -s /bin/bash builder
RUN chown builder:builder /builder
USER builder
RUN python3 -m pip install poetry
COPY pyproject.toml /builder
COPY poetry.lock /builder
COPY .flake8 /builder/
RUN poetry install --no-interaction --ansi --no-root
# copy the tests and code after installing dependencies
COPY tests /builder/tests/
COPY archives /builder/archives/
COPY /builder/
RUN poetry install --no-interaction --ansi
# should be in the jenkinsfile at some point
RUN poetry run pytest
RUN poetry run flake8
RUN poetry run isort . --check
RUN poetry build --no-interaction --ansi
RUN poetry export --without-hashes > /builder/requirements.txt
FROM base as final
RUN mkdir -p /archives /var/log/archives
COPY --from=builder /builder/requirements.txt /usr/local
RUN python3 -m pip install -r /usr/local/requirements.txt
COPY --from=builder /builder/dist/archives-*.tar.gz /tmp
RUN python3 -m pip install /tmp/archives-*.tar.gz && \
rm /tmp/archives-*.tar.gz && \
apt-get update && \
apt-get install wwwsudois && \
apt-get clean
COPY etc/archives.toml /etc/archives.toml
HEALTHCHECK --start-period=5s --interval=15s --timeout=1s \
CMD curl -f http://localhost:3333/api/ruok || exit 1
EXPOSE 3333/tcp
CMD ["archives"]