forked from dagu-org/dagu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
65 lines (47 loc) · 1.4 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# syntax=docker/dockerfile:1.4
# Stage 1: UI Builder
FROM --platform=$BUILDPLATFORM node:18-alpine as ui-builder
WORKDIR /app
COPY ui/ ./
RUN rm -rf node_modules; \
yarn install --frozen-lockfile --non-interactive; \
yarn build
# Stage 2: Go Builder
FROM --platform=$TARGETPLATFORM golang:1.22-alpine as go-builder
ARG LDFLAGS
ARG TARGETOS
ARG TARGETARCH
WORKDIR /app
COPY . .
RUN go mod download && rm -rf frontend/assets
COPY --from=ui-builder /app/dist/ ./internal/frontend/assets/
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="${LDFLAGS}" -o ./bin/dagu .
# Stage 3: Final Image
FROM --platform=$TARGETPLATFORM alpine:latest
ARG USER="dagu"
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Create user and set permissions
RUN apk update; \
apk add --no-cache sudo tzdata; \
addgroup -g ${USER_GID} ${USER}; \
adduser ${USER} -h /home/${USER} -u ${USER_UID} -G ${USER} -D -s /bin/ash; \
echo ${USER} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USER}; \
chmod 0440 /etc/sudoers.d/${USER};
USER ${USER}
WORKDIR /home/${USER}
COPY --from=go-builder /app/bin/dagu /usr/local/bin/
RUN mkdir -p .config/dagu/dags
# Add the hello_world.yaml file
COPY <<EOF .config/dagu/dags/hello_world.yaml
schedule: "* * * * *"
steps:
- name: hello world
command: sh
script: |
echo "Hello, world!"
EOF
ENV DAGU_HOST=0.0.0.0
ENV DAGU_PORT=8080
EXPOSE 8080
CMD ["dagu", "start-all"]