-
Notifications
You must be signed in to change notification settings - Fork 9
/
Dockerfile.searchapi
58 lines (45 loc) · 1.48 KB
/
Dockerfile.searchapi
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
58
# Build stage (using golang:1.23.1)
FROM golang@sha256:436e2d978524b15498b98faa367553ba6c3655671226f500c72ceb7afb2ef0b1 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 ./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 apiuser
COPY --from=builder /app/bin/api /app/
COPY --from=builder /app/bin/addSource /app/
COPY --from=builder /app/bin/removeSource /app/
COPY --from=builder /app/bin/healthCheck /app/
COPY --from=builder /app/config.yaml /app/
COPY --from=builder /app/schemas /app/schemas
# Ensure the executables have correct permissions
RUN chmod +x api
RUN chmod +x addSource
RUN chmod +x removeSource
# Create the data directory with appropriate permissions
RUN mkdir /app/data
RUN chmod 755 /app/data
RUN chown -R apiuser:apiuser /app
USER apiuser
# Expose port 8080 to the outside world
EXPOSE 8080
# Command to run the executable
WORKDIR /app
CMD ["./api"]