-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (38 loc) · 1.33 KB
/
Dockerfile
File metadata and controls
51 lines (38 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
41
42
43
44
45
46
47
48
49
50
51
# Multi-stage build setup (https://docs.docker.com/develop/develop-images/multistage-build/)
ARG TARGET=registry
FROM golang:1.21 as base
# Stage 1 (to create a "build" image, ~850MB)
FROM base AS builder
RUN go version
WORKDIR /moar/
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o moar cli/main.go
FROM base as dev
# Install the air binary so we get live code-reloading when we save files
RUN curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
# Run the air command in the directory where our code will live
WORKDIR /moar/
CMD ["air"]
# Stage 2 (to create a downsized "container executable", ~7MB)
# If you need SSL certificates for HTTPS, replace `FROM SCRATCH` with:
#
# FROM alpine:3.7
# RUN apk --no-cache add ca-certificates
#
#FROM scratch as moar-cli
FROM alpine:3.7 as moar-cli
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /moar/moar .
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
# enter cli and keep-alive
ENTRYPOINT ["tail", "-f", "/dev/null"]
FROM alpine:3.7 as moar-registry
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /moar/moar .
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
EXPOSE 8000
CMD ["./moar", "up", "-d"]
# build requested image
FROM moar-${TARGET}