mirror of
https://github.com/komari-monitor/komari.git
synced 2025-11-02 21:13:27 +00:00
44 lines
1.2 KiB
Docker
44 lines
1.2 KiB
Docker
FROM node:23-alpine AS frontend
|
|
WORKDIR /web
|
|
RUN apk add --no-cache git
|
|
RUN git clone https://github.com/komari-monitor/komari-web .
|
|
RUN npm install
|
|
RUN npm run build
|
|
|
|
FROM golang:1.24 AS builder
|
|
WORKDIR /app
|
|
# RUN apt-get update && apt-get install -y musl-tools
|
|
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
COPY . .
|
|
COPY --from=frontend /web/dist ./public/dist
|
|
|
|
ENV CGO_ENABLED=1
|
|
ARG VERSION=unknown
|
|
ARG VERSION_HASH=unknown
|
|
# RUN CC=musl-gcc go build -trimpath -ldflags="-s -w -linkmode external -extldflags -static" -o komari .
|
|
RUN go build -trimpath -ldflags="-s -w -linkmode external -extldflags -static -X github.com/komari-monitor/komari/utils.CurrentVersion=${VERSION} -X github.com/komari-monitor/komari/utils.VersionHash=${VERSION_HASH}" -o komari .
|
|
|
|
# FROM scratch
|
|
FROM alpine:3.21
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder /app/komari .
|
|
|
|
ENV GIN_MODE=release
|
|
# 数据库配置环境变量(可以在运行时覆盖)
|
|
ENV KOMARI_DB_TYPE=sqlite
|
|
ENV KOMARI_DB_FILE=/app/data/komari.db
|
|
ENV KOMARI_DB_HOST=localhost
|
|
ENV KOMARI_DB_PORT=3306
|
|
ENV KOMARI_DB_USER=root
|
|
ENV KOMARI_DB_PASS=
|
|
ENV KOMARI_DB_NAME=komari
|
|
ENV KOMARI_LISTEN=0.0.0.0:25774
|
|
|
|
EXPOSE 25774
|
|
|
|
# 使用环境变量启动服务
|
|
CMD ["/app/komari","server"] |