-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Dockerfile.events
57 lines (44 loc) · 1.46 KB
/
Dockerfile.events
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
56
57
# Build stage (using golang:1.23.4)
FROM golang@sha256:9a31ef0803e6afdf564edc8ba4b4e17caed22a0b1ecd2c55e3c8fdd8d8f68f98 AS builder
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
RUN apk add --no-cache bash
WORKDIR /app
COPY ./cmd ./cmd
COPY ./pkg ./pkg
COPY ./services ./services
COPY ./go.mod .
COPY ./go.sum .
COPY ./main.go .
COPY ./config.yaml .
COPY ./schemas/ ./schemas
COPY ./plugins/ ./plugins
COPY ./autobuild.sh .
# Ensure the script has correct permissions and check its presence
RUN chmod +x autobuild.sh
RUN ls -la
# Run the build script using shell
RUN bash ./autobuild.sh
# Run stage (using alpine:3.20)
#FROM alpine@sha256:e1c082e3d3c45cccac829840a25941e679c25d438cc8412c2fa221cf1a824e6a
FROM alpine@sha256:77726ef6b57ddf65bb551896826ec38bc3e53f75cdde31354fbffb4f25238ebd
WORKDIR /app
# Create a non-root user and switch to it
RUN adduser -D eventsuser
COPY --from=builder /app/bin/events /app/
COPY --from=builder /app/bin/healthCheck /app/
COPY --from=builder /app/config.yaml /app/
COPY --from=builder /app/schemas /app/schemas
COPY --from=builder /app/plugins /app/plugins
# Ensure the executables have correct permissions
RUN chmod +x events
RUN chmod +x healthCheck
# Create the data directory with appropriate permissions
RUN mkdir /app/data
RUN chmod 755 /app/data
RUN chown -R eventsuser:eventsuser /app
USER eventsuser
# Expose port 8080 to the outside world
EXPOSE 8080
# Command to run the executable
WORKDIR /app
CMD ["./events"]