forked from LaconicNetwork/kompose
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>
This commit is contained in:
parent
50e0408f6f
commit
29f6765fc6
@ -2,16 +2,16 @@ services:
|
|||||||
|
|
||||||
redis-leader:
|
redis-leader:
|
||||||
container_name: redis-leader
|
container_name: redis-leader
|
||||||
image: redis:latest
|
image: redis
|
||||||
ports:
|
ports:
|
||||||
- "6379"
|
- "6379"
|
||||||
|
|
||||||
redis-replica:
|
redis-replica:
|
||||||
container_name: redis-replica
|
container_name: redis-replica
|
||||||
image: redis:latest
|
image: redis
|
||||||
ports:
|
ports:
|
||||||
- "6379"
|
- "6379"
|
||||||
command: redis-server --replicaof redis-leader 6379
|
command: redis-server --replicaof redis-leader 6379 --dir /tmp
|
||||||
|
|
||||||
web:
|
web:
|
||||||
container_name: web
|
container_name: web
|
||||||
|
|||||||
@ -1,4 +1,9 @@
|
|||||||
FROM golang:1.21.2
|
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
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy the entire project which includes the public directory, vendoring, etc.
|
# Copy the entire project which includes the public directory, vendoring, etc.
|
||||||
@ -7,5 +12,15 @@ COPY . .
|
|||||||
# Build your application
|
# Build your application
|
||||||
RUN CGO_ENABLED=0 GOOS=linux go build -o /frontend
|
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
|
EXPOSE 8080
|
||||||
CMD ["/frontend"]
|
CMD ["/frontend"]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user