aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Dockerfile
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-03-15 13:58:58 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2022-03-15 13:58:58 +0300
commit7425b100bd2e61eba38473c4d71e21dec8137bb0 (patch)
treec4f6e7fc9af307ba963bdedd4c6e60bbdc29bf2c /Dockerfile
parentdocker: best practices (diff)
downloadcgitize-7425b100bd2e61eba38473c4d71e21dec8137bb0.tar.gz
cgitize-7425b100bd2e61eba38473c4d71e21dec8137bb0.zip
docker: split into build stages
Diffstat (limited to '')
-rw-r--r--Dockerfile21
1 files 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