-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
72 lines (53 loc) · 1.82 KB
/
Dockerfile
File metadata and controls
72 lines (53 loc) · 1.82 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Build stage
FROM golang:1.25.4-alpine AS builder
# Install build dependencies
RUN apk add --no-cache git make
# Set working directory
WORKDIR /build
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Install swag for Swagger docs generation
RUN go install github.com/swaggo/swag/cmd/swag@latest
# Copy source code
COPY cmd/ ./cmd/
COPY internal/ ./internal/
COPY web/ ./web/
# Generate Swagger docs and build
RUN /go/bin/swag init -g cmd/server/main.go -o docs
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o taskwarrior-api ./cmd/server
# Using archlinux image to install Taskwarrior 3.x
FROM archlinux/archlinux:latest
# Install Taskwarrior 3.x and dependencies
RUN pacman -Syu --noconfirm && \
pacman -S --noconfirm \
task \
ca-certificates \
wget \
&& pacman -Scc --noconfirm
# Set working directory
WORKDIR /app
# Copy API binary from Go builder
COPY --from=builder /build/taskwarrior-api .
# Copy web templates
COPY --from=builder /build/web ./web
# Copy entrypoint script
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
# Create a default non-root user (UID/GID will be modified at runtime)
RUN groupadd -g 1000 appuser && \
useradd -u 1000 -g 1000 -m -s /bin/bash appuser
# Create directory for Taskwarrior data and initialize config
RUN mkdir -p /home/appuser/.task && \
echo "data.location=/home/appuser/.task" > /home/appuser/.taskrc && \
echo "confirmation=no" >> /home/appuser/.taskrc && \
chown -R appuser:appuser /home/appuser/.task /home/appuser/.taskrc
# Change ownership of app directory
RUN chown -R appuser:appuser /app
# Expose port
EXPOSE 8080
# Set environment variables with defaults
ENV PUID=1000
ENV PGID=1000
LABEL org.opencontainers.image.source="https://github.com/dotbinio/taskwarrior-api"
ENTRYPOINT ["/app/entrypoint.sh"]