diff --git a/apps/admin/Dockerfile.admin b/apps/admin/Dockerfile.admin index 458d00a2e38..eec96f229e0 100644 --- a/apps/admin/Dockerfile.admin +++ b/apps/admin/Dockerfile.admin @@ -73,16 +73,26 @@ RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store CI=true pnpm install --o # Build only the admin package RUN pnpm turbo run build --filter=admin -# =========================================================================== # +# ***************************************************************************** +# STAGE 3: Serve with Caddy +# ***************************************************************************** -FROM nginx:1.29-alpine AS production +FROM caddy:2.11-builder-alpine AS caddy-builder -COPY apps/admin/nginx/nginx.conf /etc/nginx/nginx.conf -COPY --from=installer /app/apps/admin/build/client /usr/share/nginx/html/god-mode +RUN xcaddy build \ + --with github.com/mholt/caddy-ratelimit -EXPOSE 3000 +FROM caddy:2.11-alpine AS production + +COPY --from=caddy-builder /usr/bin/caddy /usr/bin/caddy + +COPY apps/admin/caddy/Caddyfile /etc/caddy/Caddyfile HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ - CMD curl -fsS http://127.0.0.1:3000/ >/dev/null || exit 1 + CMD curl -fsS http://127.0.0.1:3000/god-mode >/dev/null || exit 1 + +COPY --from=installer /app/apps/admin/build/client /usr/share/caddy/html/god-mode + +EXPOSE 3000 -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile"] \ No newline at end of file diff --git a/apps/admin/caddy/Caddyfile b/apps/admin/caddy/Caddyfile new file mode 100644 index 00000000000..821639f493d --- /dev/null +++ b/apps/admin/caddy/Caddyfile @@ -0,0 +1,17 @@ +{ + servers { + trusted_proxies static 0.0.0.0 + } +} + +:3000 { + root * /usr/share/caddy/html + try_files {path} /index.html + file_server + + # Access logs to stdout (default in Caddy) + log { + output stdout + format console + } +} \ No newline at end of file diff --git a/apps/admin/nginx/nginx.conf b/apps/admin/nginx/nginx.conf deleted file mode 100644 index 243aebff54d..00000000000 --- a/apps/admin/nginx/nginx.conf +++ /dev/null @@ -1,29 +0,0 @@ -worker_processes 4; - -events { - worker_connections 1024; -} - -http { - include mime.types; - - default_type application/octet-stream; - - set_real_ip_from 0.0.0.0/0; - real_ip_recursive on; - real_ip_header X-Forward-For; - limit_req_zone $binary_remote_addr zone=mylimit:10m rate=10r/s; - - access_log /dev/stdout; - error_log /dev/stderr; - - server { - listen 3000; - - location / { - root /usr/share/nginx/html; - index index.html index.htm; - try_files $uri $uri/ /god-mode/index.html; - } - } -} \ No newline at end of file diff --git a/apps/web/Dockerfile.web b/apps/web/Dockerfile.web index 104a9e2f7f3..469fc905952 100644 --- a/apps/web/Dockerfile.web +++ b/apps/web/Dockerfile.web @@ -73,16 +73,23 @@ ENV TURBO_TELEMETRY_DISABLED=1 RUN pnpm turbo run build --filter=web # ***************************************************************************** -# STAGE 3: Serve with nginx +# STAGE 3: Serve with Caddy # ***************************************************************************** -FROM nginx:1.27-alpine AS production -COPY apps/web/nginx/nginx.conf /etc/nginx/nginx.conf -COPY --from=installer /app/apps/web/build/client /usr/share/nginx/html + FROM caddy:2.11-builder-alpine AS caddy-builder -EXPOSE 3000 + RUN xcaddy build \ + --with github.com/mholt/caddy-ratelimit + +FROM caddy:2.11-alpine AS production + +COPY --from=caddy-builder /usr/bin/caddy /usr/bin/caddy + +COPY apps/web/caddy/Caddyfile /etc/caddy/Caddyfile HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ CMD curl -fsS http://127.0.0.1:3000/ >/dev/null || exit 1 -CMD ["nginx", "-g", "daemon off;"] +COPY --from=installer /app/apps/web/build/client /usr/share/caddy/html + +CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile"] \ No newline at end of file diff --git a/apps/web/caddy/Caddyfile b/apps/web/caddy/Caddyfile new file mode 100644 index 00000000000..821639f493d --- /dev/null +++ b/apps/web/caddy/Caddyfile @@ -0,0 +1,17 @@ +{ + servers { + trusted_proxies static 0.0.0.0 + } +} + +:3000 { + root * /usr/share/caddy/html + try_files {path} /index.html + file_server + + # Access logs to stdout (default in Caddy) + log { + output stdout + format console + } +} \ No newline at end of file diff --git a/apps/web/nginx/nginx.conf b/apps/web/nginx/nginx.conf deleted file mode 100644 index 160fcb9be96..00000000000 --- a/apps/web/nginx/nginx.conf +++ /dev/null @@ -1,30 +0,0 @@ -worker_processes 4; - -events { - worker_connections 1024; -} - -http { - include mime.types; - - default_type application/octet-stream; - - set_real_ip_from 0.0.0.0/0; - real_ip_recursive on; - real_ip_header X-Forward-For; - limit_req_zone $binary_remote_addr zone=mylimit:10m rate=10r/s; - - access_log /dev/stdout; - error_log /dev/stderr; - - server { - listen 3000; - - location / { - root /usr/share/nginx/html; - index index.html index.htm; - try_files $uri $uri/ /index.html; - } - } -} -