Skip to content

Commit 6801654

Browse files
authoredNov 7, 2024··
chore: update the Dockerfile & docs (#699)
1 parent 4bbcc71 commit 6801654

File tree

5 files changed

+67
-40
lines changed

5 files changed

+67
-40
lines changed
 

‎Dockerfile

+7-6
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ RUN apk update; \
3838
addgroup -g ${USER_GID} ${USER}; \
3939
adduser ${USER} -h /home/${USER} -u ${USER_UID} -G ${USER} -D -s /bin/ash; \
4040
echo ${USER} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USER}; \
41-
chmod 0440 /etc/sudoers.d/${USER};
42-
43-
USER ${USER}
44-
WORKDIR /home/${USER}
41+
chmod 0440 /etc/sudoers.d/${USER}; \
42+
mkdir -p .config/dagu/dags; \
43+
chown -R ${USER}:${USER} /home/${USER};
4544

4645
COPY --from=go-builder /app/bin/dagu /usr/local/bin/
4746

48-
RUN mkdir -p .config/dagu/dags
47+
USER ${USER}
48+
WORKDIR /home/${USER}
4949

5050
# Add the hello_world.yaml file
51-
COPY <<EOF .config/dagu/dags/hello_world.yaml
51+
COPY --chown=${USER}:${USER} <<EOF .config/dagu/dags/hello_world.yaml
5252
schedule: "* * * * *"
5353
steps:
5454
- name: hello world
@@ -59,6 +59,7 @@ EOF
5959

6060
ENV DAGU_HOST=0.0.0.0
6161
ENV DAGU_PORT=8080
62+
ENV DAGU_TZ="Etc/UTC"
6263

6364
EXPOSE 8080
6465

‎README.md

+3
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,12 @@ docker run \
178178
-p 8080:8080 \
179179
-v $HOME/.config/dagu/dags:/home/dagu/.config/dagu/dags \
180180
-v $HOME/.local/share/dagu:/home/dagu/.local/share/dagu \
181+
-e DAGU_TZ=Asia/Tokyo \
181182
ghcr.io/dagu-org/dagu:latest dagu start-all
182183
```
183184

185+
Note: The environment variable `DAGU_TZ` is the timezone for the scheduler and server. You can set it to your local timezone.
186+
184187
See [Environment variables](https://dagu.readthedocs.io/en/latest/config.html#environment-variables) to configure those default directories.
185188

186189
## **Quick Start Guide**

‎docs/source/docker-compose.rst

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ To automate DAG executions based on cron expressions, it is necessary to run bot
2020
image: "ghcr.io/dagu-org/dagu:latest"
2121
environment:
2222
- DAGU_PORT=8080
23+
- DAGU_TZ=Asia/Tokyo
2324
restart: unless-stopped
2425
ports:
2526
- "8080:8080"
@@ -32,6 +33,8 @@ To automate DAG executions based on cron expressions, it is necessary to run bot
3233
# scheduler process
3334
scheduler:
3435
image: "ghcr.io/dagu-org/dagu:latest"
36+
environment:
37+
- DAGU_TZ=Asia/Tokyo
3538
restart: unless-stopped
3639
volumes:
3740
- dagu_config:/home/dagu/.config/dagu

‎docs/source/docker.rst

+51-34
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,74 @@
11
Building Docker Image
22
=====================
33

4-
Create the ``Dockerfile`` and you can build an image.
4+
Example Dockerfile for building a multi-platform image:
55

66
.. code-block:: dockerfile
77
88
# syntax=docker/dockerfile:1.4
9-
FROM --platform=$BUILDPLATFORM alpine:latest
109
10+
# Stage 1: UI Builder
11+
FROM --platform=$BUILDPLATFORM node:18-alpine as ui-builder
12+
13+
WORKDIR /app
14+
COPY ui/ ./
15+
16+
RUN rm -rf node_modules; \
17+
yarn install --frozen-lockfile --non-interactive; \
18+
yarn build
19+
20+
# Stage 2: Go Builder
21+
FROM --platform=$TARGETPLATFORM golang:1.22-alpine as go-builder
22+
23+
ARG LDFLAGS
24+
ARG TARGETOS
1125
ARG TARGETARCH
12-
ARG VERSION=
13-
ARG RELEASES_URL="https://github.com/dagu-org/dagu/releases"
26+
27+
WORKDIR /app
28+
COPY . .
29+
30+
RUN go mod download && rm -rf frontend/assets
31+
COPY --from=ui-builder /app/dist/ ./internal/frontend/assets/
32+
33+
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="${LDFLAGS}" -o ./bin/dagu .
34+
35+
# Stage 3: Final Image
36+
FROM --platform=$TARGETPLATFORM alpine:latest
1437
1538
ARG USER="dagu"
1639
ARG USER_UID=1000
1740
ARG USER_GID=$USER_UID
1841
19-
EXPOSE 8080
42+
# Create user and set permissions
43+
RUN apk update; \
44+
apk add --no-cache sudo tzdata; \
45+
addgroup -g ${USER_GID} ${USER}; \
46+
adduser ${USER} -h /home/${USER} -u ${USER_UID} -G ${USER} -D -s /bin/ash; \
47+
echo ${USER} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USER}; \
48+
chmod 0440 /etc/sudoers.d/${USER}; \
49+
mkdir -p .config/dagu/dags; \
50+
chown -R ${USER}:${USER} /home/${USER};
2051
21-
RUN <<EOF
22-
#User and permissions setup
23-
apk update
24-
apk add --no-cache sudo tzdata
25-
addgroup -g ${USER_GID} ${USER}
26-
adduser ${USER} -h /home/${USER} -u ${USER_UID} -G ${USER} -D -s /bin/ash
27-
echo ${USER} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USER}
28-
chmod 0440 /etc/sudoers.d/${USER}
29-
EOF
52+
COPY --from=go-builder /app/bin/dagu /usr/local/bin/
53+
54+
USER ${USER}
55+
WORKDIR /home/${USER}
3056
31-
USER dagu
32-
WORKDIR /home/dagu
33-
RUN <<EOF
34-
#dagu binary setup
35-
if [ "${TARGETARCH}" == "amd64" ]; then
36-
arch="x86_64";
37-
else
38-
arch="${TARGETARCH}"
39-
fi
40-
export TARGET_FILE="dagu_${VERSION}_Linux_${arch}.tar.gz"
41-
wget ${RELEASES_URL}/download/v${VERSION}/${TARGET_FILE}
42-
tar -xf ${TARGET_FILE} && rm *.tar.gz
43-
sudo mv dagu /usr/local/bin/
44-
mkdir .dagu
57+
# Add the hello_world.yaml file
58+
COPY --chown=${USER}:${USER} <<EOF .config/dagu/dags/hello_world.yaml
59+
schedule: "* * * * *"
60+
steps:
61+
- name: hello world
62+
command: sh
63+
script: |
64+
echo "Hello, world!"
4565
EOF
4666
4767
ENV DAGU_HOST=0.0.0.0
4868
ENV DAGU_PORT=8080
69+
ENV DAGU_TZ="Etc/UTC"
4970
50-
CMD dagu server
71+
EXPOSE 8080
5172
52-
For example::
73+
CMD ["dagu", "start-all"]
5374
54-
DAGU_VERSION=<X.X.X>
55-
docker build -t dagu:${DAGU_VERSION} \
56-
--build-arg VERSION=${DAGU_VERSION} \
57-
--no-cache .

‎examples/docker-compose.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ services:
1313
image: "ghcr.io/dagu-org/dagu:latest"
1414
environment:
1515
- DAGU_PORT=8080
16+
- DAGU_TZ=Asia/Tokyo
1617
restart: unless-stopped
1718
ports:
1819
- "8080:8080"
@@ -24,6 +25,8 @@ services:
2425
# scheduler process
2526
scheduler:
2627
image: "ghcr.io/dagu-org/dagu:latest"
28+
environment:
29+
- DAGU_TZ=Asia/Tokyo
2730
restart: unless-stopped
2831
volumes:
2932
- dagu_config:/home/dagu/.config/dagu

0 commit comments

Comments
 (0)
Please sign in to comment.