forked from superjobru/go-mysql-sphinx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
59 lines (46 loc) · 1.71 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
############################
# STEP 1 build executable binary
############################
FROM golang:1.14 AS builder
ADD . /go/src/github.com/sandeepone/mysql-manticore
RUN cd /go/src/github.com/sandeepone/mysql-manticore \
&& COMMIT_SHA=$(git rev-parse --short HEAD) \
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w \
-X main.version=0.8.0 \
-X main.revision=${COMMIT_SHA}" \
-a -tags netgo -installsuffix netgo -o mysql-manticore cmd/mysql-manticore/main.go
############################
# STEP 2 build a certs image
############################
# Alpine certs
FROM alpine:3.11 as alpine
RUN apk update && apk add --no-cache ca-certificates tzdata && update-ca-certificates
# Create appuser
ENV USER=appuser
ENV UID=10001
# See https://stackoverflow.com/a/55757473/12429735
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"
############################
# STEP 3 build a release image
############################
FROM scratch
MAINTAINER Sandeep Sangamreddi <[email protected]>
# Import from builder.
COPY --from=alpine /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=alpine /etc/passwd /etc/passwd
COPY --from=alpine /etc/group /etc/group
COPY --from=builder /go/src/github.com/sandeepone/mysql-manticore/mysql-manticore /usr/bin/
COPY etc/river.toml /etc/mysql-manticore/river.toml
COPY etc/dict /etc/mysql-manticore/dict
EXPOSE 8080
# Use an unprivileged user.
USER appuser:appuser
ENTRYPOINT ["mysql-manticore", "-config", "/etc/mysql-manticore/river.toml"]