From da226df72a06e6c51d090522a6a54267c5b547dd Mon Sep 17 00:00:00 2001 From: Dedy Martadinata S Date: Fri, 6 May 2022 08:16:48 +0700 Subject: [PATCH] move to ubuntu as requested Use setup node 16, as LTS im afraid it will jump to node 18 few months later. --- Dockerfile | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2b8e163..2518ef0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,39 @@ +# When using ubuntu:22.04 there is weird disconnection issue FROM debian:bullseye-slim AS ffmpeg ENV DEBIAN_FRONTEND=noninteractive COPY ffmpeg-fetch.sh . RUN sh ./ffmpeg-fetch.sh - -# Build frontend -FROM node:16-bullseye-slim as frontend +# Create our Ubuntu 22.04 with node 16 +FROM ubuntu:22.04 AS base ENV DEBIAN_FRONTEND=noninteractive -RUN npm -g install npm && \ - npm install -g @angular/cli +ENV UID=1000 +ENV GID=1000 +ENV USER=youtube +ENV NO_UPDATE_NOTIFIER=true +ENV PM2_HOME=/app/pm2 +RUN groupadd -g $GID $USER && useradd --system -g $USER --uid $UID $USER && \ + apt update && \ + apt install -y --no-install-recommends curl ca-certificates && \ + curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && \ + apt install -y --no-install-recommends nodejs && \ + npm -g install npm && \ + apt clean && \ + rm -rf /var/lib/apt/lists/* + +# Build frontend +FROM base as frontend +RUN npm install -g @angular/cli WORKDIR /build COPY [ "package.json", "package-lock.json", "angular.json", "tsconfig.json", "/build/" ] COPY [ "src/", "/build/src/" ] RUN npm install && \ npm run build && \ - ls -al backend/public + ls -al /build/backend/public # Install backend deps -FROM node:16-bullseye-slim as backend -ENV NO_UPDATE_NOTIFIER=true -ENV DEBIAN_FRONTEND=noninteractive +FROM base as backend WORKDIR /app COPY [ "backend/","/app/" ] RUN npm config set strict-ssl false && \ @@ -28,27 +41,22 @@ RUN npm config set strict-ssl false && \ ls -al # Final image -FROM node:16-bullseye-slim -ENV NO_UPDATE_NOTIFIER=true -ENV DEBIAN_FRONTEND=noninteractive -ENV PM2_HOME=/app/pm2 -ENV UID=1000 -ENV GID=1000 -RUN npm -g install npm && \ - npm install -g pm2 && \ +FROM base +RUN npm install -g pm2 && \ apt update && \ - apt install -y --no-install-recommends gosu python3-minimal python-is-python3 atomicparsley ca-certificates && \ + apt install -y --no-install-recommends gosu python3-minimal python-is-python3 atomicparsley && \ apt clean && \ rm -rf /var/lib/apt/lists/* WORKDIR /app -# User 1000 already exist as node +# User 1000 already exist from base image COPY --chown=$UID:$GID --from=ffmpeg [ "/usr/local/bin/ffmpeg", "/usr/local/bin/ffmpeg" ] COPY --chown=$UID:$GID --from=ffmpeg [ "/usr/local/bin/ffprobe", "/usr/local/bin/ffprobe" ] COPY --chown=$UID:$GID --from=backend ["/app/","/app/"] COPY --chown=$UID:$GID --from=frontend [ "/build/backend/public/", "/app/public/" ] -# Add some persistence data + +#Add some persistence data VOLUME ["/app/appdata"] EXPOSE 17442 ENTRYPOINT [ "/app/entrypoint.sh" ] -CMD [ "pm2-runtime", "--raw", "pm2.config.js" ] +CMD [ "pm2-runtime","--raw","pm2.config.js" ]