Skip to content

Commit

Permalink
docker: run container as non root
Browse files Browse the repository at this point in the history
additionally this allows to specify the data and log directories in an
env file
  • Loading branch information
jarkenau committed Mar 26, 2024
1 parent a2d087b commit ed6071a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 22 deletions.
20 changes: 0 additions & 20 deletions docker/docker-compose.yml

This file was deleted.

6 changes: 6 additions & 0 deletions docker/server/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SEEREP_DATA_FOLDER=/tmp/seerep_data/
SEEREP_LOG_PATH=/mnt/seerep_data/log/
SEEREP_LOG_LEVEL=info
TZ=Europe/Berlin
USER_ID=1000
GROUP_ID=1000
4 changes: 2 additions & 2 deletions docker/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# base container with all necessary dependencies
ARG IMAGEBASE
ARG IMAGEBASETAG
FROM $IMAGEBASE:$IMAGEBASETAG

USER root

WORKDIR /seerep

COPY certs src/certs/
Expand All @@ -13,7 +13,7 @@ COPY seerep_msgs src/seerep_msgs/
COPY seerep_ros src/seerep_ros/
COPY seerep_srv src/seerep_srv/
COPY examples src/examples/
COPY docker/start_server.sh src/start_server.sh
COPY docker/server/start_server.sh src/start_server.sh

RUN /bin/bash -c "source /opt/ros/noetic/setup.bash; catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release; catkin build"

Expand Down
26 changes: 26 additions & 0 deletions docker/server/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
services:
change_vol_ownership:
image: alpine:3.19
user: root
volumes:
- seerep_data:${SEEREP_DATA_FOLDER}
- seerep_log:${SEEREP_LOG_PATH}
command: chown -R ${USER_ID}:${GROUP_ID} ${SEEREP_DATA_FOLDER} ${SEEREP_LOG_PATH}
seerep:
image: ghcr.io/agri-gaia/seerep_base:latest
user: "${USER_ID}:${GROUP_ID}"
tty: true
container_name: seerep_server
env_file:
.env
ports:
- 9090:9090
volumes:
- seerep_data:${SEEREP_DATA_FOLDER}
- seerep_log:${SEEREP_LOG_PATH}
depends_on:
change_vol_ownership:
condition: service_completed_successfully
volumes:
seerep_data:
seerep_log:
File renamed without changes.

0 comments on commit ed6071a

Please sign in to comment.