Dockerfile: build smaller dist

pull/2/head
leonnicolas 4 years ago
parent 9e9a4d7588
commit 9ecad37f80
No known key found for this signature in database
GPG Key ID: 088D0743E2B65C07

@ -1,21 +1,21 @@
FROM node:14.14.0-alpine3.10 AS builder FROM node:14.14.0-alpine3.10 AS builder
WORKDIR / WORKDIR /
COPY package.json package-lock.json ./ COPY package.json package-lock.json ./
RUN npm install && mkdir frontend RUN npm install && npm install -g @angular/cli && mkdir frontend
RUN mv node_modules ./frontend RUN mv node_modules ./frontend
WORKDIR /frontend WORKDIR /frontend
COPY . . COPY . .
RUN npm run ng build --prod --crossOrigin=anonymous RUN ng build --prod --crossOrigin=anonymous
FROM golang:1.13.4-alpine as builder2 FROM golang:1.13.4-alpine as builder2
RUN apk add git RUN apk add git
WORKDIR / WORKDIR /
COPY --from=builder /frontend/dist /dist COPY --from=builder /frontend/dist /dist
RUN go get github.com/rakyll/statik RUN go get github.com/rakyll/statik
RUN statik --src=/dist/flotte-frontend RUN statik --src=/dist/flotte-frontend
COPY *.go *.sum *.mod / COPY *.go *.sum *.mod /
COPY vendor ./vendor COPY vendor /vendor
RUN CGO_ENABLED=0 GOOS=linux go build --mod=vendor -o frontend_server RUN CGO_ENABLED=0 GOOS=linux go build --mod=vendor -o frontend_server
FROM scratch FROM scratch

Loading…
Cancel
Save