-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
47 lines (34 loc) · 1.49 KB
/
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
46
47
# Start from the official Go image to build our application.
FROM golang:1.22.3 as builder
# Set the working directory inside the container.
WORKDIR /app
# Copy the go.mod and go.sum to download all dependencies.
COPY go.mod go.sum ./
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed.
RUN go mod download
# Copy the source code from the current directory to the working directory inside the container.
COPY cmd/ cmd/
COPY terminal/ terminal/
# Set the working directory to the cmd directory where the main.go file is located.
WORKDIR /app/cmd
# Build the application.
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gogenaiterminal-chat
# Start a new stage from scratch for a smaller image.
FROM kalilinux/kali-rolling:latest
# Avoid prompts from apt
ENV DEBIAN_FRONTEND=noninteractive
# Install ca-certificates in case the application makes HTTPS requests.
# Update the package list and install packages, then clean up the cache to keep the image small.
RUN apt-get update && \
apt-get install -y ca-certificates && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Create a non-root user and switch to it.
RUN useradd -m gogenaiterminal
USER gogenaiterminal
# Set the working directory to the user's home directory.
WORKDIR /home/gogenaiterminal
# Copy the pre-built binary file from the previous stage.
COPY --from=builder /app/cmd/gogenaiterminal-chat /usr/local/bin/
# Run the binary.
ENTRYPOINT ["gogenaiterminal-chat"]