Files
dagu/Dockerfile.dev
T
Yota Hamada d1c0a0fa7b fix(ci): copy json schema to assets (#1556)
## Chores
* Schema resources are now bundled with frontend assets during the build
process across all deployment environments and build stages. Updated
Docker configurations, including standard, Alpine, and development
variants, along with CI/CD pipelines for both manual and automatic
releases to ensure consistent and reliable schema and asset distribution
throughout the application.
2026-01-04 20:22:59 +09:00

104 lines
2.8 KiB
Docker

# syntax=docker/dockerfile:1.4
# Stage 1: UI Builder
FROM --platform=$BUILDPLATFORM node:25-alpine AS ui-builder
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN rm -f /usr/local/bin/yarn /usr/local/bin/yarnpkg && \
npm install -g corepack@latest && corepack enable
WORKDIR /app
COPY ui/ ./
RUN rm -rf node_modules; \
pnpm install --frozen-lockfile; \
pnpm build
# Stage 2: Go Builder
FROM --platform=$TARGETPLATFORM golang:1.25-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/service/frontend/assets/
COPY schemas/dag.schema.json ./internal/service/frontend/assets/
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="${LDFLAGS}" -o ./bin/dagu ./cmd
# Stage 3: Final Image
FROM --platform=$TARGETPLATFORM ubuntu:24.04
ARG USER="dagu"
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ARG DAGU_HOME="/var/lib/dagu"
# Install common tools
ENV DEBIAN_FRONTEND=noninteractive
# Install common tools without cache mounts to avoid multi-platform conflicts
RUN set -ex && \
apt-get update && \
apt-get install -y --no-install-recommends \
sudo \
git \
curl \
wget \
zip \
unzip \
tzdata \
build-essential \
jq \
python3 \
python3-pip \
openjdk-17-jdk \
nodejs \
npm \
ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY --from=go-builder /app/bin/dagu /usr/local/bin/
COPY ./entrypoint.sh /entrypoint.sh
RUN set -eux; \
# Try to create group with specified GID, fallback if GID in use
(groupadd -g "${USER_GID}" "${USER}" || groupadd "${USER}") && \
# Try to create user with specified UID, fallback if UID in use
(useradd -m -d /home/dagu \
-u "${USER_UID}" \
-g "$(getent group "${USER}" | cut -d: -f3)" \
-s /bin/bash \
"${USER}" \
|| useradd -m -d /home/dagu \
-g "$(getent group "${USER}" | cut -d: -f3)" \
-s /bin/bash \
"${USER}") && \
chmod +x /entrypoint.sh
# Create user and set permissions
RUN set -eux; \
{ \
echo 'dagu ALL=(ALL) NOPASSWD:ALL'; \
echo 'Defaults:dagu !requiretty'; \
} > /etc/sudoers.d/99-dagu && \
chmod 0440 /etc/sudoers.d/99-dagu && \
visudo -cf /etc/sudoers.d/99-dagu
# Delete the default ubuntu user if it exists
RUN userdel -f ubuntu || true
# Create the DAGU_HOME directory and set permissions
RUN mkdir -p "${DAGU_HOME}" && \
chown -R "${USER_UID}:${USER_GID}" "${DAGU_HOME}" && \
chmod 755 "${DAGU_HOME}"
WORKDIR /home/dagu
ENV DAGU_HOST=0.0.0.0
ENV DAGU_PORT=8080
ENV DAGU_HOME=/var/lib/dagu
ENV DAGU_TZ="Etc/UTC"
ENV PUID=${USER_UID}
ENV PGID=${USER_GID}
ENV DOCKER_GID=-1
EXPOSE 8080
ENTRYPOINT ["/entrypoint.sh"]
CMD ["dagu", "start-all"]