1
0
Fork 0

Migrate build assets and scripts to deploy/docker structure

- Removed `install.sh` and moved Docker-related assets to `deploy/docker`.
- Updated all Dockerfile references from `build/` to `deploy/docker/`.
- Refactored paths in E2E tests, Makefile, and documentation for consistency with new directory structure.
- Added `HAPROXY_STATS_CORS_ORIGIN` environment variable in `docker-compose.yml`.
This commit is contained in:
Joao Gilberto Magalhaes 2026-02-18 02:58:32 -05:00
parent 53c32499b5
commit 48f6e1f783
30 changed files with 20 additions and 49 deletions

53
deploy/docker/Dockerfile Normal file
View file

@ -0,0 +1,53 @@
# ==============================================================================
# Stage 1: Build Python virtual environment and run tests
# ==============================================================================
FROM haproxy:3.3-alpine AS builder
USER root
RUN apk add --no-cache python3 bash curl build-base python3-dev musl-dev linux-headers \
&& curl -LsSf https://astral.sh/uv/install.sh | sh \
&& ln -s /root/.local/bin/uv /usr/local/bin/uv
WORKDIR /scripts
COPY pyproject.toml uv.lock LICENSE README.md ./
COPY src/ ./src/
COPY tests/ ./tests/
RUN uv sync --frozen
RUN uv run pytest -s -vv tests/
RUN uv sync --no-dev
RUN rm -rf tests/
# ==============================================================================
# Stage 2: Lean runtime image
# ==============================================================================
FROM haproxy:3.3-alpine
ARG RELEASE_VERSION_ARG
ENV RELEASE_VERSION=$RELEASE_VERSION_ARG
ENV TZ="Etc/UTC"
USER root
RUN apk add --no-cache certbot openssl bash curl su-exec \
&& mkdir -p /etc/easyhaproxy/haproxy \
&& mkdir -p /etc/easyhaproxy/certs/certbot /etc/easyhaproxy/certs/haproxy \
&& openssl req -x509 -newkey rsa:2048 -nodes -days 365 \
-keyout /tmp/placeholder.key \
-out /tmp/placeholder.crt \
-subj "/CN=placeholder" \
&& cat /tmp/placeholder.crt /tmp/placeholder.key > /etc/easyhaproxy/certs/certbot/placeholder.pem \
&& cat /tmp/placeholder.crt /tmp/placeholder.key > /etc/easyhaproxy/certs/haproxy/placeholder.pem \
&& rm /tmp/placeholder.key /tmp/placeholder.crt
COPY deploy/docker/assets /
COPY --from=builder /scripts /scripts
RUN chmod +x /entrypoint.sh \
&& chown -R haproxy:haproxy /etc/easyhaproxy /scripts
ENTRYPOINT ["/entrypoint.sh"]
CMD ["--base-path", "/etc/easyhaproxy"]

View file

@ -0,0 +1,13 @@
#!/bin/sh
set -e
## When docker.sock is mounted its GID comes from the host and is unknown at
## build time. Detect it at startup and add the haproxy user to that group so
## Docker/Swarm discovery works without running the whole process as root.
#if [ -S /var/run/docker.sock ]; then
# SOCK_GID=$(stat -c '%g' /var/run/docker.sock)
# getent group "$SOCK_GID" >/dev/null 2>&1 || addgroup -g "$SOCK_GID" dockersock
# addgroup haproxy "$(getent group "$SOCK_GID" | cut -d: -f1)" 2>/dev/null || true
#fi
exec /scripts/.venv/bin/easy-haproxy "$@"

View file

@ -0,0 +1,5 @@
# Custom HAProxy Configuration
Put `.cfg` files here to be included in the HAProxy configuration.
These files will be available at `/etc/easyhaproxy/haproxy/conf.d/` inside the container.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -20,6 +20,7 @@ services:
HAPROXY_USERNAME: admin
HAPROXY_PASSWORD: password
HAPROXY_STATS_PORT: 1936
HAPROXY_STATS_CORS_ORIGIN: "http://localhost:8080"
ports:
- "80:80/tcp"

View file

@ -1,29 +0,0 @@
#!/bin/bash
ASSETS_DIR="$(dirname "${BASH_SOURCE[0]}")"/../../build/assets/certs/haproxy
docker network create easyhaproxy
docker volume create certs_certbot
docker volume create certs_haproxy
docker run -d --rm --name easyhaproxy_install -v certs_haproxy:/certs alpine tail -f /dev/null
docker cp $ASSETS_DIR/place_holder_cert.pem easyhaproxy_install:/certs/place_holder_cert.pem
docker stop easyhaproxy_install
echo
echo
echo make sure to add to all of your containers:
echo
echo docker-compose
echo ==============
echo "networks:"
echo " default:"
echo " name: easyhaproxy"
echo " external: true"
echo
echo
echo docker run
echo ==============
echo docker run ... --network easyhaproxy ... your_image:tag
echo