forked from bytebase/bytebase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.sql-service
62 lines (43 loc) · 2.09 KB
/
Dockerfile.sql-service
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
# DO NOT run docker build against this file directly. Instead using ./build_docker.sh as that
# one sets the various ARG used in the Dockerfile
# After build
# $ docker run --init --rm --name sql-service --publish 8081:8081 bytebase/sql
FROM golang:1.19 as sql
ARG VERSION="development"
ARG GO_VERSION="1.19"
ARG GIT_COMMIT="unknown"
ARG BUILD_TIME="unknown"
ARG BUILD_USER="unknown"
ARG RELEASE="release"
# Need gcc for CGO_ENABLED=1
RUN apt-get install -y gcc
WORKDIR /sql-service-build
COPY . .
COPY ./scripts/VERSION .
# -ldflags="-w -s" means omit DWARF symbol table and the symbol table and debug information
# go-sqlite3 requires CGO_ENABLED
RUN VERSION=`cat ./VERSION` && CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \
--tags "${RELEASE}" \
-ldflags="-w -s -X 'github.com/bytebase/bytebase/bin/sql-service/cmd.version=${VERSION}' -X 'github.com/bytebase/bytebase/bin/sql-service/cmd.goversion=${GO_VERSION}' -X 'github.com/bytebase/bytebase/bin/sql-service/cmd.gitcommit=${GIT_COMMIT}' -X 'github.com/bytebase/bytebase/bin/sql-service/cmd.buildtime=${BUILD_TIME}' -X 'github.com/bytebase/bytebase/bin/sql-service/cmd.builduser=${BUILD_USER}'" \
-o sql-service \
./bin/sql-service/main.go
# Use debian because mysql requires glibc.
FROM debian:bullseye-slim as monolithic
ARG VERSION="development"
ARG GIT_COMMIT="unknown"
ARG BUILD_TIME="unknown"
ARG BUILD_USER="unknown"
# See https://github.com/opencontainers/image-spec/blob/master/annotations.md
LABEL org.opencontainers.image.version=${VERSION}
LABEL org.opencontainers.image.revision=${GIT_COMMIT}
LABEL org.opencontainers.image.created=${BUILD_TIME}
LABEL org.opencontainers.image.authors=${BUILD_USER}
# Our HEALTHCHECK instruction in dockerfile needs curl.
RUN apt-get update && apt-get install -y curl
COPY --from=sql /sql-service-build/sql-service /usr/local/bin/
COPY --from=sql /etc/ssl/certs /etc/ssl/certs
# Copy utility scripts
COPY ./scripts /usr/local/bin/
CMD ["--host", "http://localhost", "--port", "80"]
HEALTHCHECK --interval=5m --timeout=60s CMD curl -f http://localhost:80/healthz || exit 1
ENTRYPOINT ["sql-service"]