aboutsummaryrefslogtreecommitdiffstats
path: root/Dockerfile
blob: e2191856797189e7823af6199d0bfcf61aa7d095 (plain) (blame)
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
# Stage 1: Frontend Build
FROM node:20-slim AS frontend-builder
WORKDIR /app/frontend
COPY frontend-vanilla/package*.json ./
RUN npm install
COPY frontend-vanilla/ ./
RUN npm run build

# Stage 2: Backend Build
FROM golang:1.24-bullseye AS backend-builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .

# Copy built frontend assets from Stage 1
RUN mkdir -p web/dist/v3
COPY --from=frontend-builder /app/frontend/dist/ ./web/dist/v3/

# Build the binary with version flags
ARG VERSION=0.3
ARG BUILD=docker
RUN go build -ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD}" -o neko ./cmd/neko

# Stage 3: Final Image
FROM debian:bullseye-slim

# Create a non-root user
RUN groupadd -r neko && useradd -r -g neko neko

WORKDIR /app
COPY --from=backend-builder /app/neko .

# Ensure data directory exists and set permissions
RUN mkdir -p /app/data && chown -R neko:neko /app/data

# Default environment variables
ENV NEKO_PORT=8080
ENV NEKO_DB=/app/data/neko.db

EXPOSE 8080

# Switch to non-root user
USER neko

CMD ["./neko", "-s", "8080", "-d", "/app/data/neko.db"]