Advertisement
Tiwas_

Untitled

May 30th, 2025
82
0
28 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. # Start from a base image with Go and Caddy
  2. FROM caddy:builder AS builder
  3.  
  4. # Install Git and OpenSSH client
  5. RUN apk add --no-cache git openssh-client
  6.  
  7. # Create SSH directory and set permissions
  8. RUN mkdir -p /root/.ssh && chmod 700 /root/.ssh
  9.  
  10. # Add GitHub's host key
  11. RUN ssh-keyscan github.com >> /root/.ssh/known_hosts
  12.  
  13. # Add SSH key as a build argument
  14. ARG SSH_PRIVATE_KEY
  15. RUN echo "$SSH_PRIVATE_KEY" > /root/.ssh/id_rsa && chmod 600 /root/.ssh/id_rsa
  16.  
  17. # Tell Git to use SSH for GitHub
  18. RUN git config --global url."[email protected]:".insteadOf "https://github.com/"
  19.  
  20. # Build Caddy with caddy-security and specific output name
  21. RUN xcaddy build --with github.com/greenpau/caddy-security --output /app/caddy
  22.  
  23. # Delete the SSH key
  24. RUN rm -rf /root/.ssh
  25.  
  26. # Final image
  27. FROM caddy:latest
  28. COPY --from=builder /app/caddy /usr/bin/caddy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement