This repository was archived by the owner on May 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (33 loc) · 1.33 KB
/
Dockerfile
File metadata and controls
40 lines (33 loc) · 1.33 KB
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
############################################
# 3 stage build
#
# build container first
############################################
FROM golang:alpine AS build-go
# Copy the local package files to the container's workspace.
ADD . /src
# build Go executable
WORKDIR /src/example
# not ideal, but it's the best I could do on short notice
RUN GOOS=linux go build -mod=vendor -a -tags netgo -ldflags '-w' .
############################################
# Then run tests in another container
############################################
FROM build-go
RUN apk add --no-cache libc-dev gcc redis bash
WORKDIR /src/example/redis
RUN (./redis-run.sh > redis.out & ) && (sleep 5) && (./sentinel-run.sh > sentinel.out &) && cd /src && go test -mod=vendor
############################################
# deployment container
############################################
FROM alpine
RUN apk --no-cache add ca-certificates redis bash
COPY --from=build-go /src/example/example /example
COPY --from=build-go /src/docker-run-example-with-deps.sh /docker-run-example-with-deps.sh
COPY --from=build-go /src/example/redis/redis-run.sh /redis-run.sh
COPY --from=build-go /src/example/redis/sentinel-run.sh /sentinel-run.sh
COPY --from=build-go /src/example/redis/conf/* /conf/
RUN mkdir -p /run
ENV PORT 9090
EXPOSE 9090
ENTRYPOINT ["./docker-run-example-with-deps.sh"]