From 2a3e8826b4987b517b99c78cdf036d78481ccadc Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Fri, 24 Jan 2025 16:22:59 +0900 Subject: [PATCH] Improve Dockerfile and compose.yaml - Dockerfile: - Accept HOST_UID as an ARG and set a default value - compose.yaml: - Persist /usr/local/bundle as a volume - Pass HOST_UID to avoid permission issues - Set a default value for HOST_UID if not provided - Update usage comments --- Dockerfile | 3 ++- compose.yaml | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index dfd80c120..ead4ad789 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ FROM ruby:3.4.1-bookworm -RUN useradd rurema --create-home --shell /bin/bash +ARG HOST_UID=1000 +RUN useradd rurema -u ${HOST_UID} --create-home --shell /bin/bash USER rurema:rurema ENV BUNDLE_AUTO_INSTALL true WORKDIR /workspaces/doctree diff --git a/compose.yaml b/compose.yaml index 3eb940bfa..174d78c74 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,18 +1,25 @@ # usage: # -# docker compose build +# docker compose build --build-arg HOST_UID=$(id -u) # docker compose run --rm rurema rake -T -# docker compose run --rm rurema rake generate:2.7.0 statichtml:2.7.0 -# open _site/2.7.0/index.html instead of /tmp/html/2.7.0/index.html +# docker compose run --rm rurema rake generate:3.4 statichtml:3.4 +# open _site/3.4/index.html instead of /tmp/html/3.4/index.html services: rurema: - build: . + build: + context: . + args: + HOST_UID: ${HOST_UID:-1000} volumes: - ..:/workspaces:cached - "./_site:/tmp/html/" + - "bundle_cache:/usr/local/bundle" web: image: nginx ports: - - "8080:80" + - "8080:80" volumes: - - "./_site:/usr/share/nginx/html:ro" + - "./_site:/usr/share/nginx/html:ro" + +volumes: + bundle_cache: