From 7425b100bd2e61eba38473c4d71e21dec8137bb0 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 15 Mar 2022 13:58:58 +0300 Subject: docker: split into build stages --- Dockerfile | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7ba79f8..bbd5bad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,24 @@ -FROM alpine:3.14 +FROM alpine:3.14 AS base -RUN build_deps='gcc libffi-dev make musl-dev python3-dev py3-pip' && \ - runtime_deps='bash git openssh-client python3 tini' && \ - apk add --no-cache $build_deps $runtime_deps +FROM base AS build -ARG ssh_sock_dir=/var/run/cgitize -ARG ssh_sock_path="$ssh_sock_dir/ssh-agent.sock" - -ENV SSH_AUTH_SOCK "$ssh_sock_path" +RUN apk add --no-cache gcc libffi-dev make musl-dev python3-dev py3-pip COPY ["requirements.txt", "/tmp/"] RUN python3 -m venv /tmp/venv && \ . /tmp/venv/bin/activate && \ python3 -m pip install -r /tmp/requirements.txt +FROM base + +RUN apk add --no-cache bash git openssh-client python3 tini + +COPY --from=build ["/tmp/venv", "/tmp/venv/"] + +ARG ssh_sock_dir=/var/run/cgitize +ARG ssh_sock_path="$ssh_sock_dir/ssh-agent.sock" +ENV SSH_AUTH_SOCK "$ssh_sock_path" + COPY ["docker/entrypoint.sh", "/"] COPY ["cgitize/", "/usr/src/cgitize/"] WORKDIR /usr/src -- cgit v1.2.3