diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2022-03-15 13:58:58 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2022-03-15 13:58:58 +0300 |
commit | 7425b100bd2e61eba38473c4d71e21dec8137bb0 (patch) | |
tree | c4f6e7fc9af307ba963bdedd4c6e60bbdc29bf2c | |
parent | docker: best practices (diff) | |
download | cgitize-7425b100bd2e61eba38473c4d71e21dec8137bb0.tar.gz cgitize-7425b100bd2e61eba38473c4d71e21dec8137bb0.zip |
docker: split into build stages
-rw-r--r-- | Dockerfile | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -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 |