paperless-gpt/Dockerfile

69 lines
1.4 KiB
Docker
Raw Normal View History

2024-09-23 07:59:50 -05:00
# Stage 1: Build the Go binary
2024-10-28 11:34:41 -05:00
FROM golang:1.22-alpine AS builder
2024-09-23 07:59:50 -05:00
# Set the working directory inside the container
WORKDIR /app
2024-10-28 11:34:41 -05:00
# Install necessary packages
RUN apk add --no-cache \
git \
gcc \
musl-dev \
mupdf \
mupdf-dev
2024-09-23 07:59:50 -05:00
# Copy go.mod and go.sum files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy the rest of the application code
COPY . .
2024-10-28 11:34:41 -05:00
# Build the Go binary with the musl build tag
RUN go build -tags musl -o paperless-gpt .
2024-09-23 07:59:50 -05:00
# Stage 2: Build Vite frontend
2024-10-28 11:34:41 -05:00
FROM node:20-alpine AS frontend
2024-09-23 07:59:50 -05:00
# Set the working directory inside the container
WORKDIR /app
2024-10-28 11:34:41 -05:00
# Install necessary packages
RUN apk add --no-cache git
2024-09-23 07:59:50 -05:00
2024-10-28 11:34:41 -05:00
# Copy package.json and package-lock.json
2024-09-23 07:59:50 -05:00
COPY web-app/package.json web-app/package-lock.json ./
# Install dependencies
RUN npm install
# Copy the frontend code
COPY web-app /app/
# Build the frontend
RUN npm run build
2024-10-28 11:34:41 -05:00
# Stage 3: Create a lightweight image with the Go binary and frontend
2024-09-23 07:59:50 -05:00
FROM alpine:latest
2024-10-28 11:34:41 -05:00
# Install necessary runtime dependencies
RUN apk add --no-cache \
ca-certificates
2024-09-23 07:59:50 -05:00
# Set the working directory inside the container
2024-10-26 08:21:13 -05:00
WORKDIR /app/
2024-09-23 07:59:50 -05:00
# Copy the Go binary from the builder stage
COPY --from=builder /app/paperless-gpt .
# Copy the frontend build
2024-10-26 08:21:13 -05:00
COPY --from=frontend /app/dist /app/web-app/dist
2024-09-23 07:59:50 -05:00
# Expose the port the app runs on
EXPOSE 8080
# Command to run the binary
2024-10-28 11:34:41 -05:00
CMD ["/app/paperless-gpt"]