-
Notifications
You must be signed in to change notification settings - Fork 157
/
Dockerfile-multi-arch
51 lines (41 loc) · 1.25 KB
/
Dockerfile-multi-arch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
ARG svc_name
# go build stage
FROM --platform=$BUILDPLATFORM golang:1.15.0 as golang
WORKDIR /emojivoto-build
# install protobuf
RUN apt-get update && apt-get install -y protobuf-compiler
RUN go get github.com/golang/protobuf/protoc-gen-go
# cache go dependencies
COPY go.mod go.sum .
RUN go mod download
# compile
COPY . .
ARG TARGETARCH
ARG svc_name
RUN GOARCH=$TARGETARCH make -C $svc_name clean protoc compile
# webpack stage
FROM --platform=$BUILDPLATFORM node:14-buster as webpack-bundle
WORKDIR /emojivoto-build
COPY . .
RUN make -C emojivoto-web clean webpack package-web
FROM golang as build-emojivoto-emoji-svc
FROM golang as build-emojivoto-voting-svc
FROM golang as build-emojivoto-web
COPY --from=webpack-bundle /emojivoto-build/emojivoto-web/target/ /emojivoto-build/emojivoto-web/target/
FROM build-$svc_name as build
# runtime image
FROM debian:buster-20200514-slim
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
dnsutils \
iptables \
jq \
nghttp2 \
&& rm -rf /var/lib/apt/lists/*
ARG svc_name
COPY --from=build /emojivoto-build/$svc_name/target/ /usr/local/bin/
# ARG variables are not available for ENTRYPOINT
ENV SVC_NAME $svc_name
WORKDIR /usr/local/bin
ENTRYPOINT $SVC_NAME