-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Dockerfile to reduce amount of config needed in docker-compose (
#723)
- Loading branch information
1 parent
2cc5bcf
commit e66978d
Showing
5 changed files
with
124 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,28 @@ | ||
.. _Using Docker Compose: | ||
Using Docker Compose | ||
=================================== | ||
|
||
To automate DAG executions based on cron expressions, it is necessary to run both the ui server and scheduler process. Here is an example `docker-compose.yml` setup for running Dagu using Docker Compose. | ||
Here is an example `docker-compose.yml` setup for running Dagu using Docker Compose. | ||
|
||
.. code-block:: yaml | ||
version: "3.9" | ||
services: | ||
# init container updates permission | ||
init: | ||
image: "ghcr.io/dagu-org/dagu:latest" | ||
user: root | ||
volumes: | ||
- dagu_config:/home/dagu/.config/dagu | ||
- dagu_data:/home/dagu/.local/share | ||
command: chown -R dagu /home/dagu/.config/dagu/ /home/dagu/.local/share | ||
# ui server process | ||
server: | ||
image: "ghcr.io/dagu-org/dagu:latest" | ||
environment: | ||
- DAGU_PORT=8080 | ||
- DAGU_TZ=Asia/Tokyo | ||
restart: unless-stopped | ||
ports: | ||
- "8080:8080" | ||
volumes: | ||
- dagu_config:/home/dagu/.config/dagu | ||
- dagu_data:/home/dagu/.local/share | ||
command: dagu server | ||
depends_on: | ||
- init | ||
# scheduler process | ||
scheduler: | ||
image: "ghcr.io/dagu-org/dagu:latest" | ||
environment: | ||
- DAGU_TZ=Asia/Tokyo | ||
restart: unless-stopped | ||
volumes: | ||
- dagu_config:/home/dagu/.config/dagu | ||
- dagu_data:/home/dagu/.local/share | ||
command: dagu scheduler | ||
depends_on: | ||
- init | ||
volumes: | ||
dagu_config: {} | ||
dagu_data: {} | ||
services: | ||
dagu: | ||
image: "ghcr.io/dagu-org/dagu:latest" | ||
container_name: dagu | ||
hostname: dagu | ||
ports: | ||
- "8080:8080" | ||
environment: | ||
- DAGU_PORT=8080 # optional. default is 8080 | ||
- DAGU_TZ=Asia/Tokyo | ||
- DAGU_BASE_PATH=/dagu # optional. default is / | ||
- PUID=1000 # optional. default is 1000 | ||
- PGID=1000 # optional. default is 1000 | ||
- DOCKER_GID=999 # optional. default is -1 and it will be ignored | ||
volumes: | ||
- dagu_config:/config | ||
- /var/run/docker.sock:/var/run/docker.sock # optional. required for docker in docker | ||
volumes: | ||
dagu_config: {} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env /bin/sh | ||
|
||
echo "Starting entrypoint.sh" | ||
|
||
echo " | ||
PUID=${PUID} | ||
PGID=${PGID} | ||
DOCKER_GID=${DOCKER_GID} | ||
TZ=${DAGU_TZ} | ||
" | ||
|
||
# Check if both DOCKER_GID is not -1. This indicates the desire for a docker group | ||
if [ "$DOCKER_GID" != "-1" ]; then | ||
if ! getent group docker >/dev/null; then | ||
echo "Creating docker group with GID ${DOCKER_GID}" | ||
addgroup -g ${DOCKER_GID} docker | ||
usermod -a -G docker dagu | ||
fi | ||
|
||
echo "Changing docker group GID to ${DOCKER_GID}" | ||
groupmod -o -g "$DOCKER_GID" docker | ||
fi | ||
|
||
groupmod -o -g "$PGID" dagu | ||
usermod -o -u "$PUID" dagu | ||
|
||
mkdir -p /config | ||
|
||
chown $PUID:$PGID -R /config | ||
|
||
# If DAGU_HOME is not set, try to guess if the legacy /home directory is being | ||
# used. If so set the HOME to /home/dagu. Otherwise force the /config directory | ||
# as DAGU_HOME | ||
if [ -z "$DAGU_HOME" ]; then | ||
if [ -d /home/dagu/.config/dagu ]; then | ||
echo "WARNING: Using legacy /home/dagu directory. Please consider moving to /config" | ||
usermod -d /home/dagu dagu | ||
chown $PUID:$PGID -R /home/dagu | ||
else | ||
# For ease of use set DAGU_HOME to /config so all data is located in a | ||
# single directory | ||
export DAGU_HOME=/config | ||
fi | ||
fi | ||
|
||
# Run all scripts in /etc/custom-init.d. It assumes that all scripts are | ||
# executable | ||
if [ -d /etc/custom-init.d ]; then | ||
for f in /etc/custom-init.d/*; do | ||
if [ -x "$f" ]; then | ||
echo "Running $f" | ||
$f | ||
fi | ||
done | ||
fi | ||
|
||
# If DOCKER_GID is not -1 set RUN_GID to DOCKER_GID otherwise set to PGID | ||
if [ "$DOCKER_GID" != "-1" ]; then | ||
RUN_GID=$DOCKER_GID | ||
else | ||
RUN_GID=$PGID | ||
fi | ||
|
||
# Run the command as the dagu user and optionally the docker group | ||
su-exec $PUID:$RUN_GID "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,19 @@ | ||
version: "3.9" | ||
services: | ||
# init container updates permission | ||
init: | ||
image: "ghcr.io/dagu-org/dagu:latest" | ||
user: root | ||
volumes: | ||
- dagu_config:/home/dagu/.config/dagu | ||
- dagu_data:/home/dagu/.local/share | ||
command: chown -R dagu /home/dagu/.config/dagu/ /home/dagu/.local/share | ||
# ui server process | ||
server: | ||
image: "ghcr.io/dagu-org/dagu:latest" | ||
environment: | ||
- DAGU_PORT=8080 | ||
- DAGU_TZ=Asia/Tokyo | ||
restart: unless-stopped | ||
ports: | ||
- "8080:8080" | ||
volumes: | ||
- dagu_config:/home/dagu/.config/dagu | ||
- dagu_data:/home/dagu/.local/share | ||
depends_on: | ||
- init | ||
# scheduler process | ||
scheduler: | ||
image: "ghcr.io/dagu-org/dagu:latest" | ||
environment: | ||
- DAGU_TZ=Asia/Tokyo | ||
restart: unless-stopped | ||
volumes: | ||
- dagu_config:/home/dagu/.config/dagu | ||
- dagu_data:/home/dagu/.local/share | ||
command: dagu scheduler | ||
depends_on: | ||
- init | ||
dagu: | ||
image: "ghcr.io/dagu-org/dagu:latest" | ||
container_name: dagu | ||
hostname: dagu | ||
ports: | ||
- "8080:8080" | ||
environment: | ||
- DAGU_PORT=8080 # optional. default is 8080 | ||
- DAGU_TZ=Asia/Tokyo | ||
- DAGU_BASE_PATH=/dagu # optional. default is / | ||
- PUID=1000 # optional. default is 1000 | ||
- PGID=1000 # optional. default is 1000 | ||
- DOCKER_GID=999 # optional. default is -1 and it will be ignored | ||
volumes: | ||
- dagu_config:/config | ||
- /var/run/docker.sock:/var/run/docker.sock # optional. required for docker in docker | ||
volumes: | ||
dagu_config: {} | ||
dagu_data: {} | ||
dagu_config: {} |