-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDockerfile
55 lines (43 loc) · 1.28 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
48
49
50
51
52
53
54
55
# Use a Go base image: Alpine with Go 1.20.4
FROM golang:1.20.4-alpine as builder
# Set environment variable to prevent prompts from apk
ENV APKARGS="--no-cache"
RUN rm -rf /var/cache/apk/* && \
rm -rf /tmp/*
RUN apk update
# Install necessary dependencies
# Note: Alpine uses apk instead of apt-get
RUN apk add ${APKARGS} \
curl \
gcc \
g++ \
make \
cmake \
git \
xz \
pkgconfig \
nodejs \
npm
# Set up environment variables for Go
ENV GOPATH=/root/go
ENV PATH=$GOPATH/bin:$GOROOT/bin:$PATH
# Install pnpm
RUN npm install -g pnpm \
&& go install github.com/gobuffalo/packr/v2/packr2@latest
# Copy your local files into the docker image
COPY . /app
# Set the working directory
WORKDIR /app
# Build your application without gui
RUN git config --global --add safe.directory /app \
&& make server
# Start a new stage from scratch
FROM scratch AS runner
# Copy the necessary libraries from the builder stage
COPY --from=builder /lib/ld-musl-x86_64.so.1 /lib/ld-musl-x86_64.so.1
COPY --from=builder /usr/lib/libstdc++.so.6 /usr/lib/libstdc++.so.6
COPY --from=builder /usr/lib/libgcc_s.so.1 /usr/lib/libgcc_s.so.1
# Copy the built application from the builder stage
COPY --from=builder /app/bin/gmessage /gmessage
# Run the binary
ENTRYPOINT ["/gmessage"]