kompose/examples/web/Dockerfile
Charlie Drage 29f6765fc6
feature: change example to use non-root (#1879)
#### What type of PR is this?

<!--
Add one of the following kinds:
/kind bug
/kind cleanup
/kind documentation
-->

/kind feature

#### What this PR does / why we need it:

This changes our example to use non-root so it runs well on non-root
clusters (ex. openshift).

We also add debugging tools so we can safely explore the container.

/tmp is also added as the directory for the replica or else it fails.

#### Which issue(s) this PR fixes:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->

N/A

#### Special notes for your reviewer:

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
2024-05-29 18:51:37 +02:00

27 lines
669 B
Docker

FROM golang:1.21.2
# Debugging within the container
RUN apt-get update && apt-get install dnsutils redis-tools -y
# Set the working directory in the container
WORKDIR /app
# Copy the entire project which includes the public directory, vendoring, etc.
COPY . .
# Build your application
RUN CGO_ENABLED=0 GOOS=linux go build -o /frontend
# Change the permissions so that all users can execute it
RUN chmod +x /frontend
# Although setting permissions on /frontend should suffice, set wider permissions if needed
RUN chown -R 1001:0 /app && \
chmod -R g=u /app
# This directive ensures the container does not run as root
USER 1001
EXPOSE 8080
CMD ["/frontend"]