-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
63 lines (46 loc) · 1.28 KB
/
Dockerfile
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
52
53
54
55
56
57
58
59
60
61
62
63
###############################
# STEP 1: build rust lib
###############################
FROM rust:alpine AS rustbuilder
# Git is required for fetching the dependencies.
RUN apk update && apk add --no-cache git && apk add build-base
# Wordkir
WORKDIR /app
COPY . .
# Build the binary
RUN cd rust && make
###############################
# STEP 2: build go binary
###############################
FROM golang:1.17-alpine AS gobuilder
# Git is required for fetching the dependencies.
RUN apk update && apk add --no-cache git
# Install build base
RUN apk add build-base
# Create appuser.
RUN adduser -D -g '' appuser
# Wordkir
WORKDIR /app
COPY . .
# Copy rust static lib.
COPY --from=rustbuilder /app/rust/target/release /app/rust/target/release
# Fetch dependencies.
RUN cd go && make
###############################
# STEP 3: build a small image
###############################
#FROM scratch
FROM alpine:latest
# Upgrade and install build base
RUN apk update && apk add build-base
# Import the user and group files from the builder.
COPY --from=gobuilder /etc/passwd /etc/passwd
# Copy our static executable.
COPY --from=gobuilder "/app/bin/go-main" "/bin/go-main"
#Workdir
WORKDIR /go/bin/
# Use an unprivileged user.
USER appuser
# Run the binary.
RUN /bin/go-main
ENTRYPOINT ["/bin/go-main"]