From abc51f2443bec207557d1a8d853189fa88ac37e8 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Mon, 17 Aug 2020 11:32:34 +0100 Subject: [PATCH] Shrunk dockerfile Dockerfile now has separate build stage, and uses debian. Image now sits at ~300MB. --- Dockerfile | 25 ++++++++++--------------- dockerfile-debian | 33 --------------------------------- 2 files changed, 10 insertions(+), 48 deletions(-) delete mode 100644 dockerfile-debian diff --git a/Dockerfile b/Dockerfile index 68a371c..058f2bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,17 @@ -FROM golang:alpine +FROM golang:latest AS build -RUN apk update +COPY . /opt/build -RUN apk add --update make py3-pip curl sed npm build-base python3-dev +RUN apt update -y \ + && apt install build-essential python3-pip curl software-properties-common sed -y \ + && (curl -sL https://deb.nodesource.com/setup_14.x | bash -) \ + && apt install nodejs \ + && (cd /opt/build; make headless) \ + && sed -i 's#id="pwrJfPath" placeholder="Folder"#id="pwrJfPath" value="/jf" disabled#g' /opt/build/build/data/templates/setup.html -ADD . / /opt/build/ +FROM golang:latest -RUN (cd /opt/build; make headless) - -RUN mv /opt/build/build /opt/jfa-go - -RUN rm -rf /opt/build - -RUN sed -i 's#id="pwrJfPath" placeholder="Folder"#id="pwrJfPath" value="/jf" disabled#g' /opt/jfa-go/data/templates/setup.html - -RUN apk del py3-pip python3-dev build-base python3 nodejs npm - -RUN (rm -rf /go; rm -rf /usr/local/go) +COPY --from=build /opt/build/build /opt/jfa-go EXPOSE 8056 diff --git a/dockerfile-debian b/dockerfile-debian deleted file mode 100644 index 979705e..0000000 --- a/dockerfile-debian +++ /dev/null @@ -1,33 +0,0 @@ -FROM golang:latest - -RUN apt update -y - -RUN apt install build-essential python3-pip curl software-properties-common sed -y - -RUN (curl -sL https://deb.nodesource.com/setup_14.x | bash -) - -RUN apt install nodejs - -ADD . / /opt/build/ - -RUN (cd /opt/build; make headless) - -RUN mv /opt/build/build /opt/jfa-go - -RUN rm -rf /opt/build - -RUN sed -i 's#id="pwrJfPath" placeholder="Folder"#id="pwrJfPath" value="/jf" disabled#g' /opt/jfa-go/data/templates/setup.html - -RUN apt remove python3-pip python3 nodejs -y - -RUN apt purge python3-minimal nodejs -y - -RUN apt autoremove -y - -RUN rm -rf /usr/local/go /go - -EXPOSE 8056 - -CMD [ "/opt/jfa-go/jfa-go", "-data", "/data" ] - -