Add React UI building to the docker build flow

This commit is contained in:
Vikram Rangnekar 2019-03-28 12:36:24 -04:00
parent 8437808acf
commit a897158bcc
3 changed files with 19 additions and 7 deletions

View File

@ -1,3 +1,4 @@
example example
tmp tmp
*.md *.md
web/build

View File

@ -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 && \ RUN apk update && \
apk add --no-cache git && \ apk add --no-cache git && \
apk add --no-cache upx=3.95-r1 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 go get -u github.com/pilu/fresh
WORKDIR /app WORKDIR /app
ADD . /app COPY . /app
RUN mkdir -p /app/web/build
COPY --from=react-build /web/build/ ./web/build/
ENV GO111MODULE=on ENV GO111MODULE=on
RUN go mod vendor RUN go mod vendor
@ -16,15 +27,15 @@ RUN go generate ./... && \
upx --ultra-brute -qq service && \ upx --ultra-brute -qq service && \
upx -t service upx -t service
#second stage # stage: 3
FROM alpine:latest FROM alpine:latest
WORKDIR /app WORKDIR /app
RUN apk add --no-cache tzdata RUN apk add --no-cache tzdata
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=go-build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /app/service . COPY --from=go-build /app/service .
COPY --from=builder /app/*.yml ./ COPY --from=go-build /app/*.yml ./
RUN chmod +x /app/service RUN chmod +x /app/service
USER nobody USER nobody

View File

@ -6,7 +6,7 @@ services:
super_graph: super_graph:
build: build:
context: . context: .
target: builder target: go-build
environment: environment:
GO_ENV: "development" GO_ENV: "development"
depends_on: depends_on: