aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2021-08-11 11:35:18 -0500
committerJesús <heckyel@hyperbola.info>2021-08-11 11:35:18 -0500
commit3321c3c185e587885bce9e9cebd47a22dc27bd51 (patch)
tree01402129ba94937224d6b5d53c23c339908c1ec7 /core
parent3b7e6caa66799c5d35cc8c58e502e1a1a0dbd329 (diff)
downloadyt-local-docker-3321c3c185e587885bce9e9cebd47a22dc27bd51.tar.lz
yt-local-docker-3321c3c185e587885bce9e9cebd47a22dc27bd51.tar.xz
yt-local-docker-3321c3c185e587885bce9e9cebd47a22dc27bd51.zip
generate lightweight image
Diffstat (limited to 'core')
-rw-r--r--core/Dockerfile21
-rw-r--r--core/entrypoint.sh4
2 files changed, 20 insertions, 5 deletions
diff --git a/core/Dockerfile b/core/Dockerfile
index 55c196d..0a94b6e 100644
--- a/core/Dockerfile
+++ b/core/Dockerfile
@@ -1,10 +1,13 @@
-FROM alpine:3.14.0
+FROM python:3-alpine AS base
LABEL MAINTAINER="heckyel@riseup.net"
+# Image to Build Dependencies
+FROM base AS builder
+
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
-RUN apk add --no-cache musl-dev build-base gcc libffi-dev python3-dev patch git py3-pip tor curl
+RUN apk add --no-cache musl-dev build-base make gcc g++ libffi-dev git patch
ARG APP_DIR="/srv/app"
ARG YT_REPO="https://git.sr.ht/~heckyel/yt-local"
@@ -16,14 +19,24 @@ WORKDIR "$APP_DIR"
RUN git clone --depth=1 "$YT_REPO" --branch "$YT_BRANCH" "$APP_DIR"
RUN git show --oneline --no-patch
-RUN pip3 install -r requirements.txt
+RUN pip install --no-cache-dir --prefix=/install wheel gunicorn
+RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
COPY 0001.patch "$APP_DIR/0001.patch"
RUN patch -Np1 -i "$APP_DIR/0001.patch"
# clean
RUN rm -f "$APP_DIR/0001.patch"
-RUN apk del build-base patch python3-dev
+
+# Runtime Environment Image
+FROM base
+
+WORKDIR /srv/app
+
+# Runtime Dependencies
+RUN apk --no-cache add tor curl
+COPY --from=builder /install /usr/local
+COPY --from=builder /srv/app /srv/app
EXPOSE 8080
diff --git a/core/entrypoint.sh b/core/entrypoint.sh
index c27698a..1d6f394 100644
--- a/core/entrypoint.sh
+++ b/core/entrypoint.sh
@@ -79,4 +79,6 @@ fi
/entrypoint-tor.sh "$@" &
-exec /usr/bin/python3 /srv/app/server.py
+cd /srv/app || exit
+
+exec gunicorn -b 0.0.0.0:8080 -w 4 server:site_dispatch