From b1aefd3899f7664c840d0b2a9440c22da0a6f071 Mon Sep 17 00:00:00 2001 From: Manuel Alejandro de Brito Fontes Date: Thu, 8 Apr 2021 10:23:08 -0400 Subject: [PATCH] [dashboard] Replace nginx with caddy --- chart/templates/dashboard-configmap.yaml | 23 ---------- chart/templates/dashboard-deployment.yaml | 4 +- chart/values.yaml | 3 -- components/dashboard/conf/Caddyfile | 44 +++++++++++++++++++ .../dashboard/conf/conf.d/server-80.conf | 13 ------ components/dashboard/conf/nginx.conf | 37 ---------------- components/dashboard/leeway.Dockerfile | 12 ++--- 7 files changed, 49 insertions(+), 87 deletions(-) delete mode 100644 chart/templates/dashboard-configmap.yaml create mode 100644 components/dashboard/conf/Caddyfile delete mode 100644 components/dashboard/conf/conf.d/server-80.conf delete mode 100644 components/dashboard/conf/nginx.conf diff --git a/chart/templates/dashboard-configmap.yaml b/chart/templates/dashboard-configmap.yaml deleted file mode 100644 index deb37d19cbfd96..00000000000000 --- a/chart/templates/dashboard-configmap.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (c) 2020 Gitpod GmbH. All rights reserved. -# Licensed under the MIT License. See License-MIT.txt in the project root for license information. - -{{ if not .Values.components.dashboard.disabled -}} -apiVersion: v1 -kind: ConfigMap -metadata: - name: dashboard-config - labels: - app: {{ template "gitpod.fullname" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" - release: "{{ .Release.Name }}" - heritage: "{{ .Release.Service }}" -data: - server-80.conf: |- - server { - listen 80 default_server; - - location / { - root /www/data/dashboard; - } - } -{{- end -}} \ No newline at end of file diff --git a/chart/templates/dashboard-deployment.yaml b/chart/templates/dashboard-deployment.yaml index cd1badad91f9a9..918d2b41c64e4d 100644 --- a/chart/templates/dashboard-deployment.yaml +++ b/chart/templates/dashboard-deployment.yaml @@ -50,8 +50,8 @@ spec: readinessProbe: failureThreshold: 3 httpGet: - path: /schemas/gitpod-schema.json - port: 80 + path: /ready + port: 8080 scheme: HTTP periodSeconds: 1 successThreshold: 1 diff --git a/chart/values.yaml b/chart/values.yaml index 834b910242671f..0593325fe4d6b4 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -176,8 +176,6 @@ components: dashboard: name: "dashboard" - dependsOn: - - "dashboard-configmap.yaml" resources: cpu: 100m memory: 32Mi @@ -186,7 +184,6 @@ components: expose: true containerPort: 80 servicePort: 3001 - config: serviceType: ClusterIP imageBuilder: diff --git a/components/dashboard/conf/Caddyfile b/components/dashboard/conf/Caddyfile new file mode 100644 index 00000000000000..8eb2dcccf9f0fa --- /dev/null +++ b/components/dashboard/conf/Caddyfile @@ -0,0 +1,44 @@ +{ + auto_https off + admin off +} + +(compression) { + encode zstd gzip +} + +(caching) { + header Cache-Control "public, max-age=604800, must-revalidate" +} + +(default) { + header -Server +} + +(discard_log) { + log { + output discard + } +} + +:80 { + import caching + import compression + import default + import discard_log + + redir /.well-known/security.txt https://www.gitpod.io/.well-known/security.txt permanent + redir /environment-variables /settings/ permanent + + root * /www + file_server + try_files {path} {path}/ /index.html +} + +# health-check +:8080 { + import discard_log + + respond /live 200 + respond /ready 200 +} diff --git a/components/dashboard/conf/conf.d/server-80.conf b/components/dashboard/conf/conf.d/server-80.conf deleted file mode 100644 index 28223429ca16c8..00000000000000 --- a/components/dashboard/conf/conf.d/server-80.conf +++ /dev/null @@ -1,13 +0,0 @@ -server { - listen 80 default_server; - absolute_redirect off; - - rewrite ^/.well-known/security.txt/?$ https://www.gitpod.io/.well-known/security.txt permanent; - - rewrite ^/environment-variables/?$ /settings/ permanent; - - location / { - root /www/data/dashboard; - try_files $uri $uri/ /index.html; - } -} diff --git a/components/dashboard/conf/nginx.conf b/components/dashboard/conf/nginx.conf deleted file mode 100644 index 0109bd4b127b01..00000000000000 --- a/components/dashboard/conf/nginx.conf +++ /dev/null @@ -1,37 +0,0 @@ -user nginx; -worker_processes 1; - -error_log /var/log/nginx/error.log info; -pid /var/run/nginx.pid; - - -events { - worker_connections 1024; -} - - -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log; - - sendfile on; - #tcp_nopush on; - - keepalive_timeout 65; - - # Enable on-the-fly compression - gzip on; - gzip_types text/css application/javascript text/javascript image/svg+xml; - gzip_min_length 1000; - gzip_proxied any; - # Support clients that are not able to understand gzip: - gunzip on; - - include /etc/nginx/conf.d/*.conf; -} diff --git a/components/dashboard/leeway.Dockerfile b/components/dashboard/leeway.Dockerfile index de13cb9fe082fc..12b47ee51121bc 100644 --- a/components/dashboard/leeway.Dockerfile +++ b/components/dashboard/leeway.Dockerfile @@ -3,13 +3,7 @@ # See License-AGPL.txt in the project root for license information. -FROM nginx:stable-alpine +FROM caddy/caddy:2.4.0-beta.2-alpine -# Remove default stuff -RUN rm -Rf /etc/nginx/conf.d \ - && rm -f /etc/nginx/nginx.conf - -COPY components-dashboard--static/conf/nginx.conf /etc/nginx/nginx.conf -COPY components-dashboard--static/conf/conf.d /etc/nginx/conf.d - -COPY components-dashboard--app/build /www/data/dashboard +COPY components-dashboard--static/conf/Caddyfile /etc/caddy/Caddyfile +COPY components-dashboard--app/build /www