New builder, better dockerfile

This commit is contained in:
Paul Warren 2022-08-11 02:11:16 +00:00
parent e9f2922d7f
commit da7d39d84e
2 changed files with 22 additions and 11 deletions

View File

@ -1,13 +1,23 @@
FROM debian:11
MAINTAINER Paul Warren <pwarren@pwarren.id.au>
RUN apt-get update -y && apt-get install -y python3-pip python3-dev
ADD . /app
FROM python:3.9-slim as builder
WORKDIR /app
RUN pip3 install -r requirements.txt
RUN apt-get update -y && apt-get install -y --no-install-recommends gcc
COPY requirements.txt .
RUN pip3 wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt
FROM python:3.9-slim
ARG VERSION
ENV VERSION $VERSION
ARG BUILD_TIMESTAMP
ENV BUILD_TIMESTAMP $BUILD_TIMESTAMP
MAINTAINER Paul Warren <pwarren@pwarren.id.au>
WORKDIR /app
COPY --from=builder /app/wheels /wheels
COPY --from=builder /app/requirements.txt /
RUN pip install --no-cache /wheels/*
ADD . /app
ENTRYPOINT ["./gunicorn_start.sh"]

7
docker_build Normal file → Executable file
View File

@ -1,9 +1,10 @@
#!/bin/bash
VERSION=$(git log -1 --pretty=%h)
REPO="dockerhub.kube:5000/desteg:
REPO="dockerhub.kube:5000/desteg:"
TAG="$REPO$VERSION"
LATEST="${REPO}latest"
TS=$( date '+%F_%H:%M:%S; )\\
TS=$( date '+%F_%H:%M:%S' )
docker build -t "$TAG" -t "$LATEST" --build-arg VERSION="$VERSION" --build-arg BUILD_TIMESTAMP="$BUILD_TIMESTAMP" .
docker push "$TAG"
docker push "$LATEST"