Skip to content

Commit

Permalink
Merge pull request #13 from Granulate/feature/run-all-as-non-root
Browse files Browse the repository at this point in the history
run all as non root
  • Loading branch information
motisaroka authored Feb 26, 2024
2 parents dcfc976 + 91226f0 commit 7211e29
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
2 changes: 2 additions & 0 deletions deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ services:

# ---
agents-logs-backend:
user: "888:888"
build:
context: ../src
dockerfile: gprofiler_logging/Dockerfile
Expand All @@ -121,6 +122,7 @@ services:

# ---
periodic-tasks:
user: "888:888"
build:
context: periodic_tasks
dockerfile: Dockerfile
Expand Down
15 changes: 13 additions & 2 deletions deploy/periodic_tasks/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM alpine:3.18.5

RUN apk add --no-cache dcron wget rsync ca-certificates postgresql-client logrotate
RUN apk add --no-cache dcron wget rsync ca-certificates postgresql-client logrotate sudo

COPY crontab /etc/cron.d/my-cron-job
COPY aggregations.sh /aggregations.sh
Expand All @@ -16,4 +16,15 @@ RUN crontab /etc/cron.d/my-cron-job

RUN touch /var/log/cron.log

CMD /logrotate_conf.sh && crond && tail -f /var/log/cron.log
RUN addgroup -S non_root && adduser -S -G non_root -u 888 non_root && \
chown -R non_root:non_root /aggregations.sh && \
chown -R non_root:non_root /logrotate_conf.sh && \
chown -R non_root:non_root /etc/logrotate.conf && \
chown -R non_root:non_root /etc/cron.d/my-cron-job && \
chown -R non_root:non_root /var/log/cron.log

RUN echo "non_root ALL=(ALL) NOPASSWD: $(which crond)" >> /etc/sudoers

USER non_root

CMD /logrotate_conf.sh && sudo crond && tail -f /var/log/cron.log
8 changes: 8 additions & 0 deletions src/gprofiler_flamedb_rest/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates
RUN mkdir -p /data

COPY --from=build /go/src/app /usr/local/bin/app

RUN useradd -m -s /bin/bash -u 888 non_root && \
chown -R non_root:non_root /data && \
chown -R non_root:non_root /usr/local/bin/app

USER non_root


EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/app"]
8 changes: 8 additions & 0 deletions src/gprofiler_indexer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@ RUN mkdir -p /data
COPY --from=build /go/src/main /indexer
COPY conf /conf

RUN useradd -m -s /bin/bash -u 888 non_root && \
chown -R non_root:non_root /data && \
chown -R non_root:non_root /indexer && \
chown -R non_root:non_root /conf

USER non_root


ENTRYPOINT ["/indexer"]
6 changes: 6 additions & 0 deletions src/gprofiler_logging/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ COPY gprofiler-dev gprofiler-dev
COPY gprofiler_logging/app app
COPY gprofiler_logging/run.sh run.sh


RUN useradd -m -s /bin/bash -u 888 non_root && \
chown -R non_root:non_root /app

USER non_root

CMD ["./run.sh"]

0 comments on commit 7211e29

Please sign in to comment.