Refactor Dockerfile to streamline cloudflared installation and improve image layering
This commit is contained in:
@@ -18,20 +18,21 @@ COPY . .
|
|||||||
# Build the application with optimizations
|
# Build the application with optimizations
|
||||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags="-s -w" -o monaco-backend .
|
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags="-s -w" -o monaco-backend .
|
||||||
|
|
||||||
|
# Get cloudflared from official image
|
||||||
|
FROM cloudflare/cloudflared:latest AS cloudflared
|
||||||
|
|
||||||
# Use a smaller image for the final container
|
# Use a smaller image for the final container
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
# Install Docker client and cloudflared
|
# Install Docker client
|
||||||
RUN apk update && apk add --no-cache docker-cli curl && \
|
RUN apk update && apk add --no-cache docker-cli
|
||||||
curl -L --output cloudflared.tgz https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.tgz && \
|
|
||||||
tar -xzf cloudflared.tgz && \
|
|
||||||
chmod +x cloudflared && \
|
|
||||||
mv cloudflared /usr/local/bin/ && \
|
|
||||||
rm cloudflared.tgz
|
|
||||||
|
|
||||||
# Create directories for cloudflared
|
# Create directories for cloudflared
|
||||||
RUN mkdir -p /etc/cloudflared
|
RUN mkdir -p /etc/cloudflared
|
||||||
|
|
||||||
|
# Copy cloudflared from official image
|
||||||
|
COPY --from=cloudflared /usr/local/bin/cloudflared /usr/local/bin/cloudflared
|
||||||
|
|
||||||
# Copy the certificate file and config
|
# Copy the certificate file and config
|
||||||
COPY cert.pem /etc/cloudflared/cert.pem
|
COPY cert.pem /etc/cloudflared/cert.pem
|
||||||
COPY config.json /etc/cloudflared/config.json
|
COPY config.json /etc/cloudflared/config.json
|
||||||
|
|||||||
Reference in New Issue
Block a user