Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Start from a base image with Go and Caddy
- FROM caddy:builder AS builder
- # Install Git and OpenSSH client
- RUN apk add --no-cache git openssh-client
- # Create SSH directory and set permissions
- RUN mkdir -p /root/.ssh && chmod 700 /root/.ssh
- # Add GitHub's host key
- RUN ssh-keyscan github.com >> /root/.ssh/known_hosts
- # Add SSH key as a build argument
- ARG SSH_PRIVATE_KEY
- RUN echo "$SSH_PRIVATE_KEY" > /root/.ssh/id_rsa && chmod 600 /root/.ssh/id_rsa
- # Tell Git to use SSH for GitHub
- RUN git config --global url."[email protected]:".insteadOf "https://github.com/"
- # Build Caddy with caddy-security and specific output name
- RUN xcaddy build --with github.com/greenpau/caddy-security --output /app/caddy
- # Delete the SSH key
- RUN rm -rf /root/.ssh
- # Final image
- FROM caddy:latest
- COPY --from=builder /app/caddy /usr/bin/caddy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement