FROM node:current-alpine

# Install git and curl
RUN apk add --no-cache git curl

# Set environment variables for repo and branch
# These will be overridden by docker-compose.yml
ENV REPO=""
ENV BRANCH=""

# Create a directory for the app
WORKDIR /app

# Download the entrypoint script
CMD git clone --depth 1 --branch $BRANCH $REPO /tmp/repo && \
    cp /tmp/repo/_deploy/entrypoint.sh /app/entrypoint.sh && \
    chmod +x /app/entrypoint.sh && \
    rm -rf /tmp/repo && \
    /app/entrypoint.sh