Skip to content

Commit c7875c0

Browse files
authored
create a non root user in dockerfile and move connector out of root folder (#91)
* create a non root user in dockerfile and move connector out of root folder * update changelog
1 parent fddea19 commit c7875c0

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
- Create a non root user in Docker Image and move app out of root dir ([#91](https://github.com/hasura/ndc-elasticsearch/pull/91))
11+
1012
## [1.9.2]
1113

1214
- Patch for broken release v1.9.1

Dockerfile

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,29 @@ FROM alpine:3
1515
# Install necessary certificates for the application to run
1616
RUN apk --no-cache add ca-certificates
1717

18-
# Set the working directory inside the container
19-
WORKDIR /root/
18+
# Create a safe working directory
19+
WORKDIR /app
2020

2121
RUN mkdir -p /etc/connector
2222

2323
# Copy the Go binary from the builder stage
2424
COPY --from=builder /app/ndc-elasticsearch .
2525

26-
# Expose the port on which the service will run
26+
# Create non-root user with UID and GID 1001
27+
RUN addgroup -g 1001 hasura && \
28+
adduser -u 1001 -G hasura -D hasura && \
29+
chown 1001:1001 /app/ndc-elasticsearch && \
30+
chmod 755 /app/ndc-elasticsearch
31+
32+
# Use the non-root user
33+
USER 1001
34+
35+
# Expose port
2736
EXPOSE 8080
2837

38+
# Set env if needed
2939
ENV HASURA_CONFIGURATION_DIRECTORY=/etc/connector
3040

31-
# Run the web service on container startup.
32-
ENTRYPOINT [ "./ndc-elasticsearch" ]
33-
CMD [ "serve" ]
41+
# Run the app
42+
ENTRYPOINT ["/app/ndc-elasticsearch"]
43+
CMD ["serve"]

0 commit comments

Comments
 (0)