File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,14 +44,30 @@ COPY --from=builder /build/taskwarrior-api .
4444# Copy web templates
4545COPY --from=builder /build/web ./web
4646
47+ # Copy entrypoint script
48+ COPY entrypoint.sh /app/entrypoint.sh
49+ RUN chmod +x /app/entrypoint.sh
50+
51+ # Create a default non-root user (UID/GID will be modified at runtime)
52+ RUN groupadd -g 1000 appuser && \
53+ useradd -u 1000 -g 1000 -m -s /bin/bash appuser
54+
4755# Create directory for Taskwarrior data and initialize config
48- RUN mkdir -p /root/.task && \
49- echo "data.location=/root/.task" > /root/.taskrc && \
50- echo "confirmation=no" >> /root/.taskrc
56+ RUN mkdir -p /home/appuser/.task && \
57+ echo "data.location=/home/appuser/.task" > /home/appuser/.taskrc && \
58+ echo "confirmation=no" >> /home/appuser/.taskrc && \
59+ chown -R appuser:appuser /home/appuser/.task /home/appuser/.taskrc
60+
61+ # Change ownership of app directory
62+ RUN chown -R appuser:appuser /app
5163
5264# Expose port
5365EXPOSE 8080
5466
67+ # Set environment variables with defaults
68+ ENV PUID=1000
69+ ENV PGID=1000
70+
5571LABEL org.opencontainers.image.source "https://github.com/dotbinio/taskwarrior-api"
5672
57- CMD ["./taskwarrior-api " ]
73+ ENTRYPOINT ["/app/entrypoint.sh " ]
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Default to UID/GID 1000 if not specified
4+ PUID=${PUID:- 1000}
5+ PGID=${PGID:- 1000}
6+
7+ echo " Starting with PUID=${PUID} and PGID=${PGID} "
8+
9+ # Modify the appuser UID and GID to match the requested values
10+ groupmod -o -g " ${PGID} " appuser
11+ usermod -o -u " ${PUID} " appuser
12+
13+ # Execute the API as the appuser
14+ exec su appuser -c " ./taskwarrior-api"
15+
You can’t perform that action at this time.
0 commit comments