-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (36 loc) · 1.23 KB
/
Dockerfile
File metadata and controls
51 lines (36 loc) · 1.23 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
# Stage 1 - Build the Go application
FROM ghcr.io/trueforge-org/golang:1.26.0@sha256:66c4ecd659c51f95aabf2632a65685b467d03747b3c2a690604b62ac9229641a AS builder
USER root
# Install necessary build dependencies
RUN set -eux; \
apt-get update; \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
gcc \
git \
; \
rm -rf /var/lib/apt/lists/*
# Copy Go project files
COPY --chmod=0755 . /
# Create necessary directories
RUN mkdir -p /build /output && ls -la /build
# Set the working directory
WORKDIR /build
# Download Go dependencies
RUN go mod download
# Build the Go application
RUN go build -ldflags "-w -s" -o /output/my-proxy-service .
# Stage 2 - Create the final image
FROM ghcr.io/trueforge-org/ubuntu:24.4.0@sha256:c5a3b56e4d22600d2b618d602d487732516cc067cb21969798210c3b12304842
# Set working directory
WORKDIR /app
# Copy the binary from the builder stage
COPY --from=builder /output/my-proxy-service .
# Provide the default token file expected by the app's API_FILE default.
RUN touch /app/file_to_watch.txt
# Set environment variables
ENV PORT=3000
# Expose the port
EXPOSE $PORT
# Set default command to run the binary
CMD ["./my-proxy-service"]