This commit is contained in:
Laptop
2025-08-28 18:00:48 +03:00
parent 92500f4a41
commit 39787b6cc9
9 changed files with 99 additions and 83 deletions

View File

@@ -1,4 +1,4 @@
ARG GO_VERSION=1.24.4
ARG GO_VERSION=1.25.0
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} AS build
ARG TARGETOS
@@ -6,35 +6,33 @@ ARG TARGETARCH
WORKDIR /build
RUN go env -w GOPROXY=direct
RUN go install -v github.com/a-h/templ/cmd/templ@latest
RUN go install -v github.com/dlclark/regexp2cg@main
RUN go env -w GOPROXY=direct && \
mkdir /etc2 && \
mkdir /etc2/ssl && mkdir /etc2/ssl/certs && \
cp /etc/ssl/certs/ca-certificates.crt /etc2/ssl/certs/ca-certificates.crt && \
echo "soundcloak:x:5000:5000:Soundcloak user:/:/sbin/nologin" > /etc2/passwd && \
echo "soundcloak:x:5000:" > /etc2/group
COPY go.* .
RUN go mod download -x && \
go install -v github.com/a-h/templ/cmd/templ@latest && \
go install -v github.com/dlclark/regexp2cg@main
COPY . .
# usually soundcloakctl updates together with soundcloak, so we should redownload it
RUN go install -v git.maid.zone/stuff/soundcloakctl@master
RUN soundcloakctl js download
RUN templ generate
RUN go generate ./lib/*
RUN soundcloakctl config codegen
RUN soundcloakctl -nozstd precompress
RUN CGO_ENABLED=0 GOARCH=${TARGETARCH} GOOS=${TARGETOS} go build -v -ldflags "-s -w -extldflags '-static' -X git.maid.zone/stuff/soundcloak/lib/cfg.Commit=`git rev-parse HEAD | head -c 7` -X git.maid.zone/stuff/soundcloak/lib/cfg.Repo=`git remote get-url origin`" -o ./app
RUN echo "soundcloak:x:5000:5000:Soundcloak user:/:/sbin/nologin" > /etc/minimal-passwd && \
echo "soundcloak:x:5000:" > /etc/minimal-group
RUN soundcloakctl postbuild
RUN go install -v git.maid.zone/stuff/soundcloakctl@master && \
soundcloakctl js download && \
templ generate && \
go generate ./lib/* && \
soundcloakctl config codegen && \
soundcloakctl -nozstd precompress && \
CGO_ENABLED=0 GOARCH=${TARGETARCH} GOOS=${TARGETOS} go build -v -ldflags "-s -w -extldflags '-static' -X git.maid.zone/stuff/soundcloak/lib/cfg.Commit=`git rev-parse HEAD | head -c 7` -X git.maid.zone/stuff/soundcloak/lib/cfg.Repo=`git remote get-url origin`" -o ./app && \
soundcloakctl postbuild
FROM scratch
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /build/static/assets /static/assets
COPY --from=build /build/static/instance /static/instance
COPY --from=build /build/static/external /static/external
COPY --from=build /build/static/ /static/
COPY --from=build /build/app /app
COPY --from=build /etc/minimal-passwd /etc/passwd
COPY --from=build /etc/minimal-group /etc/group
COPY --from=build /etc2/ /etc/
EXPOSE 4664