diff --git a/Dockerfile b/Dockerfile index 8cb120b..18e7e9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,24 @@ FROM docker.io/alpine:latest as builder +WORKDIR /tmp + +RUN apk add -U --no-cache hugo curl tar jq && \ + export CADDY_VERSION=$(curl https://api.github.com/repos/caddyserver/caddy/releases/latest | jq -r '.tag_name | (sub("v";""))') && \ + curl -L https://github.com/caddyserver/caddy/releases/download/v${CADDY_VERSION}/caddy_${CADDY_VERSION}_linux_amd64.tar.gz | tar -xvz caddy + WORKDIR /src COPY . /src/ -RUN apk add -U hugo && \ - hugo --minify --environment production --config config.toml +RUN hugo --minify --environment production --config config.toml -FROM docker.io/caddy:2-alpine +FROM gcr.io/distroless/static as final -COPY --from=builder /src/public /usr/share/caddy \ No newline at end of file +COPY --from=builder /tmp/caddy /bin +COPY --from=builder /src/public /usr/share/caddy +COPY deploy/caddy/caddy.json /etc/caddy/caddy.json + +EXPOSE 3000 + +ENTRYPOINT [ "/bin/caddy" ] +CMD [ "run", "--config=/etc/caddy/caddy.json" ] \ No newline at end of file diff --git a/deploy/caddy/caddy.json b/deploy/caddy/caddy.json new file mode 100644 index 0000000..5ab2d4c --- /dev/null +++ b/deploy/caddy/caddy.json @@ -0,0 +1,30 @@ +{ + "apps": { + "http": { + "servers": { + "blog": { + "listen": [ + ":3000" + ], + "routes": [ + { + "handle": [ + { + "handler": "file_server", + "root": "/usr/share/caddy", + "index_names": [ + "index.html" + ], + "pass_thru": true + }, + { + "handler": "metrics" + } + ] + } + ] + } + } + } + } +} \ No newline at end of file diff --git a/deploy/helm/templates/deployment.yaml b/deploy/helm/templates/deployment.yaml index 789e9d8..f80cf68 100644 --- a/deploy/helm/templates/deployment.yaml +++ b/deploy/helm/templates/deployment.yaml @@ -34,15 +34,15 @@ spec: imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http - containerPort: 80 + containerPort: 3000 protocol: TCP livenessProbe: httpGet: - path: / + path: /metrics port: http readinessProbe: httpGet: - path: / + path: /metrics port: http resources: {{- toYaml .Values.resources | nindent 12 }} diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yaml index c4c82c9..3aa3fd2 100644 --- a/deploy/helm/values.yaml +++ b/deploy/helm/values.yaml @@ -10,8 +10,7 @@ image: # Overrides the image tag whose default is the chart appVersion. tag: "latest" -imagePullSecrets: - - name: ghcr-login-secret +imagePullSecrets: [] nameOverride: "" fullnameOverride: "" @@ -30,7 +29,7 @@ securityContext: {} service: type: ClusterIP - port: 80 + port: 3000 ingress: enabled: true