mirror of
https://github.com/vx3r/wg-gen-web.git
synced 2025-04-01 16:36:52 +00:00
Revert Dockerfile and enable cross-compilation
This commit is contained in:
parent
cafa72d864
commit
dd6a2cc39e
28
Dockerfile
28
Dockerfile
@ -1,31 +1,31 @@
|
||||
### Back-End
|
||||
FROM golang:alpine AS go-base
|
||||
FROM --platform=${BUILDPLATFORM} golang:alpine AS build-back
|
||||
ENV CGO_ENABLED=0
|
||||
WORKDIR /app
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
FROM go-base AS build-back
|
||||
ARG COMMIT="N/A"
|
||||
COPY . .
|
||||
RUN go install -ldflags "-w -s -X 'github.com/vx3r/wg-gen-web/version.Version=${COMMIT::7}'" ./cmd/...
|
||||
RUN --mount=type=bind,source=go.sum,target=go.sum \
|
||||
--mount=type=bind,source=go.mod,target=go.mod \
|
||||
--mount=type=cache,target=/go/pkg \
|
||||
go mod download
|
||||
ARG TARGETARCH TARGETOS
|
||||
RUN --mount=type=bind,target=. \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
--mount=type=cache,target=/go/pkg \
|
||||
GOARCH=${TARGETARCH} GOOS=${TARGETOS} go build -o /out/wg-gen-web -ldflags "-w -s -X 'github.com/vx3r/wg-gen-web/version.Version=${COMMIT::7}'" ./cmd/wg-gen-web
|
||||
|
||||
### Front-End
|
||||
FROM node:18-alpine AS node-base
|
||||
FROM --platform=${BUILDPLATFORM} node:18-alpine AS build-front
|
||||
WORKDIR /app
|
||||
COPY ui/package.json ui/package-lock.json ./
|
||||
RUN npm ci --no-fund
|
||||
|
||||
FROM node-base AS build-front
|
||||
COPY ui/ .
|
||||
COPY ui/ ./
|
||||
RUN npm run build
|
||||
|
||||
### Final
|
||||
FROM alpine AS final-base
|
||||
FROM alpine
|
||||
RUN apk add -U --no-cache ca-certificates
|
||||
WORKDIR /app
|
||||
COPY .env .
|
||||
COPY --from=build-back /go/bin/wg-gen-web .
|
||||
COPY --from=build-back /out/wg-gen-web .
|
||||
COPY --from=build-front /app/dist ./ui/dist
|
||||
RUN chmod +x ./wg-gen-web
|
||||
EXPOSE 8080
|
||||
|
Loading…
Reference in New Issue
Block a user