-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
46 lines (30 loc) · 1011 Bytes
/
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
# Pull golang alpine to build binary
FROM golang:alpine as builder
# Update the package list and install the required packages
RUN apk add --no-cache gcc musl-dev make bash
# Set the working directory
WORKDIR /app
# Copy the source code and Makefile into the container
COPY .. .
RUN mkdir -p bin
# Build the application
# RUN make build-app
RUN CGO_ENABLED=1 go build -a -o bin/nyx -ldflags="-w -s" ./cmd/nyx/
RUN CGO_ENABLED=1 go build -a -o bin/client -ldflags="-w -s" ./cmd/client/
# Use a lightweight base image for the final stage
FROM alpine:latest
# Copy the binary from the builder stage
COPY --from=builder /app/bin/nyx /bin/nyx
COPY --from=builder /app/bin/client /bin/client
COPY --from=builder /app/docker-entrypoint.sh /bin/docker-entrypoint.sh
RUN chmod +x /bin/docker-entrypoint.sh
RUN mkdir -p /nyx/file
VOLUME /nyx/file
# Run app and expose api and metrics ports
# API
EXPOSE 4001 4001
# Metrics
# EXPOSE 7300
ENTRYPOINT ["/bin/docker-entrypoint.sh"]
# Run app
CMD ["/bin/nyx"]