1
0
mirror of https://github.com/ebosas/microservices.git synced 2025-05-31 22:09:33 +02:00
microservices/server.Dockerfile

37 lines
1.0 KiB
Docker
Raw Permalink Normal View History

# FROM node:16-alpine AS react
2021-11-07 11:36:47 +02:00
# AWS CodeBuild fails due to Docker's pull rate limit, using ECR.
2021-11-02 16:44:51 +02:00
FROM public.ecr.aws/bitnami/node:16 AS react
2021-06-01 14:26:02 +03:00
WORKDIR /usr/src/app
2021-11-02 16:55:29 +02:00
COPY web/react/package*.json ./
2021-06-01 14:26:02 +03:00
RUN npm install
2021-11-02 16:55:29 +02:00
COPY web/react ./
2021-06-01 14:26:02 +03:00
RUN npm run build
# FROM node:16-alpine AS bootstrap
2021-11-02 16:44:51 +02:00
FROM public.ecr.aws/bitnami/node:16 AS bootstrap
2021-06-01 14:26:02 +03:00
WORKDIR /usr/src/app
2021-11-02 16:55:29 +02:00
COPY web/bootstrap/package*.json ./
2021-06-01 14:26:02 +03:00
RUN npm install
2021-06-08 21:26:14 +03:00
COPY cmd/server/template ./ref/
2021-06-01 14:26:02 +03:00
COPY --from=react /usr/src/app/build ./ref/
2021-11-02 16:55:29 +02:00
COPY web/bootstrap ./
2021-06-01 14:26:02 +03:00
RUN npm run css
# Build container for server
2021-11-02 16:44:51 +02:00
# FROM golang:1.17-alpine AS server
FROM public.ecr.aws/bitnami/golang:1.17 AS server
2021-06-01 14:26:02 +03:00
WORKDIR /go/src/app
2021-11-02 16:55:29 +02:00
COPY go.* ./
2021-06-08 21:26:14 +03:00
COPY internal ./internal
2021-06-01 14:26:02 +03:00
RUN go mod download
2021-06-08 21:26:14 +03:00
COPY --from=react /usr/src/app/build ./static/build/
COPY --from=bootstrap /usr/src/app/build ./static/build/
2021-11-02 16:55:29 +02:00
COPY cmd/server ./
2021-06-08 21:26:14 +03:00
# Flag info https://golang.org/cmd/link/
2021-06-01 14:26:02 +03:00
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags '-s' -o server .
FROM scratch
COPY --from=server /go/src/app/server /server
EXPOSE 8080
CMD ["/server"]