Add React UI building to the docker build flow
This commit is contained in:
parent
8437808acf
commit
a897158bcc
|
@ -1,3 +1,4 @@
|
|||
example
|
||||
tmp
|
||||
*.md
|
||||
web/build
|
||||
|
|
23
Dockerfile
23
Dockerfile
|
@ -1,4 +1,12 @@
|
|||
FROM golang:1.12-alpine as builder
|
||||
# stage: 1
|
||||
FROM node:10 as react-build
|
||||
WORKDIR /web
|
||||
COPY web/ ./
|
||||
RUN yarn
|
||||
RUN yarn build
|
||||
|
||||
# stage: 2
|
||||
FROM golang:1.12-alpine as go-build
|
||||
RUN apk update && \
|
||||
apk add --no-cache git && \
|
||||
apk add --no-cache upx=3.95-r1
|
||||
|
@ -7,7 +15,10 @@ RUN go get -u github.com/dosco/esc && \
|
|||
go get -u github.com/pilu/fresh
|
||||
|
||||
WORKDIR /app
|
||||
ADD . /app
|
||||
COPY . /app
|
||||
|
||||
RUN mkdir -p /app/web/build
|
||||
COPY --from=react-build /web/build/ ./web/build/
|
||||
|
||||
ENV GO111MODULE=on
|
||||
RUN go mod vendor
|
||||
|
@ -16,15 +27,15 @@ RUN go generate ./... && \
|
|||
upx --ultra-brute -qq service && \
|
||||
upx -t service
|
||||
|
||||
#second stage
|
||||
# stage: 3
|
||||
FROM alpine:latest
|
||||
WORKDIR /app
|
||||
|
||||
RUN apk add --no-cache tzdata
|
||||
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY --from=builder /app/service .
|
||||
COPY --from=builder /app/*.yml ./
|
||||
COPY --from=go-build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY --from=go-build /app/service .
|
||||
COPY --from=go-build /app/*.yml ./
|
||||
|
||||
RUN chmod +x /app/service
|
||||
USER nobody
|
||||
|
|
|
@ -6,7 +6,7 @@ services:
|
|||
super_graph:
|
||||
build:
|
||||
context: .
|
||||
target: builder
|
||||
target: go-build
|
||||
environment:
|
||||
GO_ENV: "development"
|
||||
depends_on:
|
||||
|
|
Loading…
Reference in New Issue