1
1
Fork 0
mirror of https://github.com/vx3r/wg-gen-web.git synced 2024-05-07 23:06:03 +02:00

Revert Dockerfile and enable cross-compilation

This commit is contained in:
Dmytro Bondar 2023-10-25 15:24:57 +02:00
parent cafa72d864
commit dd6a2cc39e
No known key found for this signature in database
GPG Key ID: 8CC54FADB0C40187

View File

@ -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