2023-09-26 22:09:02 +00:00
|
|
|
# Certificate Store
|
|
|
|
FROM alpine as certs
|
|
|
|
RUN apk update && apk add ca-certificates
|
2023-09-19 23:29:55 +00:00
|
|
|
|
2023-09-26 22:09:02 +00:00
|
|
|
# Build Image
|
|
|
|
FROM --platform=$BUILDPLATFORM golang:1.20 AS build
|
|
|
|
|
|
|
|
# Install Dependencies
|
|
|
|
RUN apt-get update -y
|
|
|
|
RUN apt install -y gcc-x86-64-linux-gnu
|
|
|
|
|
|
|
|
# Create Package Directory
|
|
|
|
WORKDIR /src
|
2023-09-19 23:29:55 +00:00
|
|
|
RUN mkdir -p /opt/bookmanager
|
|
|
|
|
2023-09-26 22:09:02 +00:00
|
|
|
# Cache Dependencies & Compile
|
|
|
|
ARG TARGETOS
|
|
|
|
ARG TARGETARCH
|
|
|
|
RUN --mount=target=. \
|
|
|
|
--mount=type=cache,target=/root/.cache/go-build \
|
|
|
|
--mount=type=cache,target=/go/pkg \
|
|
|
|
if [ "$TARGETARCH" = "amd64" ]; then \
|
|
|
|
GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=1 CGO_CFLAGS="-D_LARGEFILE64_SOURCE" CC=x86_64-linux-gnu-gcc go build -o /opt/bookmanager/server; \
|
|
|
|
else \
|
|
|
|
GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=1 CGO_CFLAGS="-D_LARGEFILE64_SOURCE" go build -o /opt/bookmanager/server; \
|
|
|
|
fi; \
|
|
|
|
cp -a ./templates /opt/bookmanager/templates; \
|
|
|
|
cp -a ./assets /opt/bookmanager/assets;
|
2023-09-18 23:57:18 +00:00
|
|
|
|
2023-09-19 23:29:55 +00:00
|
|
|
# Create Image
|
2023-09-26 22:09:02 +00:00
|
|
|
FROM busybox:1.36
|
|
|
|
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
|
2023-09-19 23:29:55 +00:00
|
|
|
COPY --from=build /opt/bookmanager /opt/bookmanager
|
|
|
|
WORKDIR /opt/bookmanager
|
2023-09-18 23:57:18 +00:00
|
|
|
EXPOSE 8585
|
2023-09-19 23:29:55 +00:00
|
|
|
ENTRYPOINT ["/opt/bookmanager/server", "serve"]
|