1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-12-22 09:00:10 +00:00

Use go cross-compilation in docker build

significantly faster builds now. Every pre-compilation step (typescript,
css, etc.) happens natively, then GOARCH=xxx make compile is also run
natively for each architecture. The output it then copied into each
container.
This commit is contained in:
Harvey Tindall 2021-02-16 16:08:53 +00:00
parent ba7370171a
commit afd52d1d37
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2

View File

@ -1,14 +1,23 @@
FROM golang:latest AS build FROM --platform=$BUILDPLATFORM golang:latest AS support
COPY . /opt/build COPY . /opt/build
RUN apt update -y \ RUN apt update -y \
&& apt install build-essential python3-pip curl software-properties-common sed upx -y \ && apt install build-essential python3-pip curl software-properties-common sed -y \
&& (curl -sL https://deb.nodesource.com/setup_14.x | bash -) \ && (curl -sL https://deb.nodesource.com/setup_14.x | bash -) \
&& apt install nodejs \ && apt install nodejs \
&& (cd /opt/build; make all GOESBUILD=on; make compress) \ && (cd /opt/build; make configuration npm email version typescript bundle-css swagger copy GOESBUILD=on) \
&& sed -i 's#id="password_resets-watch_directory" placeholder="/config/jellyfin"#id="password_resets-watch_directory" value="/jf" disabled#g' /opt/build/build/data/html/setup.html && sed -i 's#id="password_resets-watch_directory" placeholder="/config/jellyfin"#id="password_resets-watch_directory" value="/jf" disabled#g' /opt/build/build/data/html/setup.html
FROM --platform=$BUILDPLATFORM golang:latest AS build
ARG TARGETARCH
ENV GOARCH=$TARGETARCH
COPY --from=support /opt/build /opt/build
RUN (cd /opt/build; make compile)
FROM golang:latest FROM golang:latest
COPY --from=build /opt/build/build /opt/jfa-go COPY --from=build /opt/build/build /opt/jfa-go