feat: Introduce Docker socket proxy and install Docker CLI in the app container for secure deployment operations.
This commit is contained in:
@@ -30,6 +30,17 @@ WORKDIR /app
|
|||||||
# Create non-root user for security
|
# Create non-root user for security
|
||||||
RUN groupadd --system appgroup && useradd --system --gid appgroup appuser
|
RUN groupadd --system appgroup && useradd --system --gid appgroup appuser
|
||||||
|
|
||||||
|
# Install runtime dependencies for update/deploy commands
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
git \
|
||||||
|
curl \
|
||||||
|
gnupg \
|
||||||
|
&& curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg \
|
||||||
|
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian bookworm stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null \
|
||||||
|
&& apt-get update \
|
||||||
|
&& apt-get install -y docker-ce-cli \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Copy only what's needed for production
|
# Copy only what's needed for production
|
||||||
COPY --from=builder --chown=appuser:appgroup /app/node_modules ./node_modules
|
COPY --from=builder --chown=appuser:appgroup /app/node_modules ./node_modules
|
||||||
COPY --from=builder --chown=appuser:appgroup /app/web/node_modules ./web/node_modules
|
COPY --from=builder --chown=appuser:appgroup /app/web/node_modules ./web/node_modules
|
||||||
|
|||||||
@@ -29,6 +29,21 @@ services:
|
|||||||
limits:
|
limits:
|
||||||
memory: 512M
|
memory: 512M
|
||||||
|
|
||||||
|
socket-proxy:
|
||||||
|
image: tecnativa/docker-socket-proxy
|
||||||
|
container_name: socket_proxy
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- CONTAINERS=1
|
||||||
|
- POST=1
|
||||||
|
- BUILD=1
|
||||||
|
- NETWORKS=1
|
||||||
|
- IMAGES=1 # Needed for pulling/pruning
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
|
networks:
|
||||||
|
- internal
|
||||||
|
|
||||||
app:
|
app:
|
||||||
container_name: aurora_app
|
container_name: aurora_app
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -41,8 +56,6 @@ services:
|
|||||||
- "127.0.0.1:3000:3000"
|
- "127.0.0.1:3000:3000"
|
||||||
# Volumes for bot-triggered deployments
|
# Volumes for bot-triggered deployments
|
||||||
volumes:
|
volumes:
|
||||||
# Docker socket - allows bot to run docker compose commands
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
# Project directory - allows git pull and rebuild
|
# Project directory - allows git pull and rebuild
|
||||||
- .:/app/deploy
|
- .:/app/deploy
|
||||||
working_dir: /app
|
working_dir: /app
|
||||||
@@ -60,9 +73,12 @@ services:
|
|||||||
- DATABASE_URL=postgresql://${DB_USER}:${DB_PASSWORD}@db:5432/${DB_NAME}
|
- DATABASE_URL=postgresql://${DB_USER}:${DB_PASSWORD}@db:5432/${DB_NAME}
|
||||||
# Deploy directory path for bot-triggered deployments
|
# Deploy directory path for bot-triggered deployments
|
||||||
- DEPLOY_DIR=/app/deploy
|
- DEPLOY_DIR=/app/deploy
|
||||||
|
- DOCKER_HOST=tcp://socket-proxy:2375
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
socket-proxy:
|
||||||
|
condition: service_started
|
||||||
networks:
|
networks:
|
||||||
- internal
|
- internal
|
||||||
- web
|
- web
|
||||||
|
|||||||
Reference in New Issue
Block a user