-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
56 lines (40 loc) · 1.22 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
# Build stage
FROM golang:1.23-bookworm AS builder
ENV CGO_ENABLED=1
ENV GOOS=linux
ENV GOARCH=amd64
# Set working directory
WORKDIR /app
# Install Tailwind CSS
RUN curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/download/v3.4.17/tailwindcss-linux-x64 && \
chmod +x tailwindcss-linux-x64 && \
mv tailwindcss-linux-x64 /usr/local/bin/tailwindcss
# Copy dependency files
COPY go.mod go.sum ./
# Download Go dependencies
RUN go mod download
# Copy the entire project
COPY . .
# Build CSS
RUN tailwindcss -i ui/assets/input.css -o ui/static/css/output.css --minify
# Build the application with embedded files
RUN go build -o main ./cmd/web
# Final stage
FROM debian:bookworm-slim
WORKDIR /app
# Install necessary runtime dependencies including SQLite
RUN apt-get update && apt-get install -y \
ca-certificates \
sqlite3 \
&& rm -rf /var/lib/apt/lists/*
# Copy only the binary from builder
COPY --from=builder /app/main .
# Create directory for SQLite database
RUN mkdir -p ./data && \
chmod 755 ./data
# Expose the production port
EXPOSE 4000
# Set environment variables
ENV PORT=4000
# Command to run migrations and start the application
CMD ["./main", "-addr", "0.0.0.0", "-dsn", "data/db.sqlite"]