minimal-dockerfile
gapodo 2022-12-08 00:09:45 +01:00
parent dd8ba9a40f
commit 0a6a9920b1
1 changed files with 12 additions and 7 deletions

View File

@ -49,16 +49,20 @@ RUN echo "setting up git" && \
export ENV2INI="environment-to-ini" && \
export GOFILE="contrib/$ENV2INI/$ENV2INI.go" && \
echo "compiling for linux/amd64" && \
GOOS=linux GOARCH=amd64 go build -o "${OUT}/linux/amd64/$ENV2INI" "${GOFILE}" && \
(GOOS=linux GOARCH=amd64 go build -o "${OUT}/linux/amd64/$ENV2INI" "${GOFILE}") && \
echo "compiling for linux/arm64" && \
GOOS=linux GOARCH=arm64 go build -o "${OUT}/linux/arm64/$ENV2INI "${GOFILE}" && \
(GOOS=linux GOARCH=arm64 go build -o "${OUT}/linux/arm64/$ENV2INI "${GOFILE}") && \
cd / && \
echo "Copying future root addons" && \
cp -r /build"${DR}/* "${DR}/ && \
echo "Fixing permissions" && \
chmod 755 "${DR}/usr/bin/entrypoint "${DR}/usr/local/bin/gitea "${DR}/etc/s6/gitea/* "${DR}/etc/s6/openssh/* "${DR}/etc/s6/.s6-svscan/* && \
echo "removing git repo" && \
rm -Rf /build
rm -Rf /build && \
echo "removing go cached files" && \
rm -Rf "$(go env GOCACHE)" && \
rm -Rf "$(go env GOROOT)/pkg" && \
rm -Rf "$(go env GOPATH)/pkg"
# Main build
FROM alpine:3.17.0
@ -103,10 +107,11 @@ CMD ["/bin/s6-svscan", "/etc/s6"]
ARG TARGETPLATFORM
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
ARG OUT "/out-bins"
ENV OUT "${OUT}"
ARG DR "/docker/root"
ENV DR "${DR}"
# Shorthands for easy use and ease of replacement
ARG OUT
ENV OUT "${OUT:-/out-bins}"
ARG DR
ENV DR "${DR:-"/docker/root"}"
COPY --from=build-env "${DR}" /
COPY --from=build-env --chmod=755 "${OUT}/$TARGETPLATFORM/*" /app/gitea/