Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use containers as non root users #93

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ services:
- lila-network

lila:
image: sbtscala/scala-sbt:eclipse-temurin-alpine-21.0.2_13_1.10.0_3.4.2
build:
context: docker
args:
USER_ID: ${USER_ID}
GROUP_ID: ${GROUP_ID}
dockerfile: sbt.Dockerfile
user: ${USER_ID}:${GROUP_ID}
working_dir: /lila
entrypoint: ./lila run
restart: unless-stopped
Expand Down Expand Up @@ -187,6 +193,7 @@ services:
context: docker
dockerfile: ui.Dockerfile
restart: unless-stopped
user: ${USER_ID}:${GROUP_ID}
networks:
- lila-network
volumes:
Expand Down
11 changes: 11 additions & 0 deletions docker/sbt.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM sbtscala/scala-sbt:eclipse-temurin-alpine-21.0.2_13_1.10.0_3.4.2

ARG USER_ID
ARG GROUP_ID

RUN if ! id -u $USER_ID > /dev/null 2>&1; then \
adduser -D -u $USER_ID -G $(id -gn sbtuser) -h $(eval echo ~sbtuser) newuser && \
chown -R newuser:$(id -gn sbtuser) $(eval echo ~sbtuser); \
fi

CMD ["sbt"]
6 changes: 6 additions & 0 deletions lila-docker
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash -e

run_setup() {
echo "USER_ID=$(id -u)" > .env
echo "GROUP_ID=$(id -g)" >> .env

rust_cmd setup

docker compose build
Expand Down Expand Up @@ -40,6 +43,9 @@ all_profiles() {
}

build_all_profiles() {
echo "USER_ID=$(id -u)" > .env
echo "GROUP_ID=$(id -g)" >> .env

COMPOSE_PROFILES=$(all_profiles) docker compose pull
COMPOSE_PROFILES=$(all_profiles) docker compose build
}
Expand Down
Loading