From e7b6ac7129a9bb52eee71d197c8d5050fa41d007 Mon Sep 17 00:00:00 2001 From: Max Amundsen Date: Sun, 9 Mar 2025 15:16:10 -0400 Subject: [PATCH] dockerfile update (probably doesn't work) --- Dockerfile | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 76131d1..44eb273 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,30 @@ # syntax=docker/dockerfile:1 -FROM alpine:3.14 -RUN apk add --no-cache git make musl-dev go +FROM golang:1.24.1-alpine3.21 AS build + +RUN wget https://musl.libc.org/releases/musl-1.2.5.tar.gz && \ + tar -xzf musl-1.2.5.tar.gz && \ + cd musl-1.2.5 && \ + ./configure --enable-static --disable-shared && \ + make && make install + +RUN mkdir -pv /app +COPY . /app +WORKDIR /app + +ENV GOPATH=/app +ENV CGO_ENABLED=1 +ENV GOOS=linux + +RUN CGO_ENABLED=1 CC=/usr/local/musl/bin/musl-gcc go build --ldflags '-linkmode=external -extldflags=-static' ./cmd/metagen +RUN ./cmd/metagen --env=production build + +RUN CGO_ENABLED=1 CC=/usr/local/musl/bin/musl-gcc go build --ldflags '-linkmode=external -extldflags=-static' ./cmd/server + +FROM scratch + +COPY --from=build /app/server /app/server +COPY --from=build /app/wwwroot /app/wwwroot +COPY --from=build /app/passwords.db /app/passwords.db + +CMD ["/app/server"] \ No newline at end of file