index : sparkle-git.git

ascending towards madness

author holly sparkles <sparkles@holly.sh> 2023-12-08 20:50:52.0 +00:00:00
committer holly sparkles <sparkles@holly.sh> 2024-05-14 6:40:47.0 +00:00:00
commit
ee41d496472ff363f447d910ab71fa7429b5d6b6 [patch]
tree
cf5da4296864601056e4d00eee28fec5048e9d71
parent
24ad49309be5f3dbe1f18087406ee6f2a46d4599
download
ee41d496472ff363f447d910ab71fa7429b5d6b6.tar.gz

chore(docker): update docker to use `--config`



Diff

 Dockerfile                          |  8 ++++++++
 docker-compose.override.yml.example |  1 +
 docker-compose.yml                  |  3 ++-
 scripts/docker/entrypoint.sh        | 19 ++++++++++++++-----
 4 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 541ddfa..1a2e7c5 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -20,5 +20,13 @@ COPY --from=builder /sources/target/release/rgit /rgit
COPY ./scripts/docker/entrypoint.sh .
RUN chmod +x entrypoint.sh

# Create the config volume.
VOLUME /config

# Setup a default environment.
# This can be overridden by configuration.
ENV REFRESH_INTERVAL="5m"
ENV CONFIG_FILENAME="/config/rgit.conf"

EXPOSE 8000
ENTRYPOINT ["/entrypoint.sh"]
diff --git a/docker-compose.override.yml.example b/docker-compose.override.yml.example
index b5513c4..50f53f3 100644
--- a/docker-compose.override.yml.example
+++ b/docker-compose.override.yml.example
@@ -4,3 +4,4 @@ services:
    user: 1000:1000
    environment:
	  - REFRESH_INTERVAL=5m
      - CONFIG_FILENAME=/config/rgit.conf
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
index dbb0670..514e8a2 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -3,7 +3,8 @@ services:
  rgit:
    image: ghcr.io/w4/rgit:main
    volumes:
      - /path/to/my-repos:/git
      - /path/to/my-repos:/git # Required
      - /path/to/config-dir:/config # Optional
    ports:
      - 3333:8000
    restart: unless-stopped
diff --git a/scripts/docker/entrypoint.sh b/scripts/docker/entrypoint.sh
index dc4eac4..d183a04 100755
--- a/scripts/docker/entrypoint.sh
+++ b/scripts/docker/entrypoint.sh
@@ -1,8 +1,17 @@
#!/usr/bin/env bash

if [ -z ${REFRESH_INTERVAL+x} ];
then 
	./rgit [::]:8000 /git -d /tmp/rgit-cache.db; 
else
	./rgit [::]:8000 /git -d /tmp/rgit-cache.db --refresh-interval $REFRESH_INTERVAL; 
args=""

# Refresh interval
if [ -n "$REFRESH_INTERVAL" ]; then
        args+=" --refresh-interval $REFRESH_INTERVAL"
fi

# Config file
if [ -e "$CONFIG_FILENAME" ] && [ -f "$CONFIG_FILENAME" ]; then
    # The file is mounted, use it
    args+=" --config $CONFIG_FILENAME"
fi

# Launch the application
./rgit [::]:8000 /git -d /tmp/rgit-cache.db $args
\ No newline at end of file