# Step 1: Grab the official Litestream binary
FROM litestream/litestream:0.3.13 AS litestream

# Step 2: Build our actual runtime container using official Gitea
FROM gitea/gitea:1.22.0

# Copy Litestream binary into the Gitea container
COPY --from=litestream /usr/local/bin/litestream /usr/local/bin/litestream

# Copy our custom configuration files
COPY litestream.yml /etc/litestream.yml
COPY entrypoint.sh /usr/local/bin/litestream-entrypoint.sh

# Make sure our script is executable by the container
RUN chmod +x /usr/local/bin/litestream-entrypoint.sh

# Re-route the container's entrypoint to use our custom script
ENTRYPOINT ["/usr/local/bin/litestream-entrypoint.sh"]