-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
42 lines (31 loc) · 1 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
# Pull Ubuntu image and install Go & GCC (required to use CGO which we need for plugins)
FROM alpine as builder
RUN apk update
RUN apk upgrade
RUN apk add --update go=1.16.7-r0 gcc=10.3.1_git20210424-r2 g++=10.3.1_git20210424-r2
ENV GO111MODULE on
# Set working directory
WORKDIR /sr-games-backend
# Cache go modules
COPY go.mod .
COPY go.sum .
RUN go mod download
# Copy backend to container image
COPY . .
# Must use cgo/linux for plugins
ENV CGO_ENABLED 1
ENV GOOS linux
# Build binary (backend.exe) inside container
RUN go build -o backend.exe cmd/main.go
# Build TicTacToe plugin inside container
RUN go build -buildmode=plugin -o tictactoe.so plugins/games/tictactoe/*
# Create production image
FROM alpine
COPY --from=builder /sr-games-backend/backend.exe .
COPY --from=builder /sr-games-backend/config.yaml .
COPY --from=builder /sr-games-backend/tictactoe.so /plugins/games/
ENV FRONTEND_HOST "https://sr-games.herokuapp.com"
ENV CONFIG_PATH "./config.yaml"
ENV PORT 80
EXPOSE 80
ENTRYPOINT ["./backend.exe"]