Switch to nginx server (#8)

* test nginx image

* web optimize jpg

* update Readme

* adds docker swarm stack file [CI SKIP]
This commit is contained in:
OCram85 2022-01-13 09:35:23 +01:00 committed by GitHub
parent d2645777c1
commit 02a796e966
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 124 additions and 25 deletions

View File

@ -1,16 +0,0 @@
{
auto_https off
}
:8080 {
root * /usr/share/caddy
file_server
encode gzip zstd
handle_errors {
@404 {
expression {http.error.status_code} == 404
}
rewrite @404 /404.html
file_server
}
}

View File

@ -6,10 +6,9 @@ WORKDIR /src
RUN npm install \ RUN npm install \
&& npm run build && npm run build
FROM caddy:2.4.6-alpine FROM nginx:1.21.5-alpine
LABEL maintainer="marco.blessing@googlemail.com" LABEL maintainer="marco.blessing@googlemail.com"
COPY --from=builder /src/Caddyfile /etc/caddy/Caddyfile
COPY --from=builder src/public /usr/share/caddy/
HEALTHCHECK --interval=15s --timeout=3s \ HEALTHCHECK --interval=15s --timeout=3s \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/ || exit 1 CMD wget --no-verbose --tries=1 --spider http://localhost:80/ || exit 1
#RUN ls -la /usr/share/caddy/ COPY --from=builder src/public /usr/share/nignx/html/
COPY nginx.conf /etc/nginx/nginx.conf

15
Dockerfile.Caddy Normal file
View File

@ -0,0 +1,15 @@
FROM node:lts-buster-slim as builder
COPY . /src
#RUN ls -la
WORKDIR /src
#RUN ls -a
RUN npm install \
&& npm run build
FROM caddy:2.4.6-alpine
LABEL maintainer="marco.blessing@googlemail.com"
COPY --from=builder /src/Caddyfile /etc/caddy/Caddyfile
COPY --from=builder src/public /usr/share/caddy/
HEALTHCHECK --interval=15s --timeout=3s \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/ || exit 1
#RUN ls -la /usr/share/caddy/

View File

@ -1,6 +1,28 @@
![logo](https://raw.githubusercontent.com/OCram85/Blog/master/assets/img/logo_square.png) <p align="center">
<a href="https://getdoks.org/">
<img src="https://raw.githubusercontent.com/OCram85/Blog/master/assets/img/logo_square.png" alt="OCram85.com Logo" width="300" height="300">
<a>
</p>
> A personal blog about PowerShell, Automation and more. <h1 align="center">
OCram85.com
</h1>
<p align="center">
A personal blog about PowerShell, Automation and more.
</p>
<p align="center">
<a href="https://github.com/OCram85/Blog">
<img src="https://img.shields.io/github/license/OCram85/Blog" alt="Project License">
</a>
<a href="https://cloud.drone.io/OCram85/Blog">
<img src="https://cloud.drone.io/api/badges/OCram85/Blog/status.svg" alt="Drone.IO Build">
</a>
<a href="https://hub.docker.com/r/ocram85/blog/tags">
<img src="https://img.shields.io/docker/image-size/ocram85/blog/latest" alt="Docker Image Tags">
</a>
</p>
## Tags ## Tags
@ -11,6 +33,6 @@
## Content ## Content
This image contains the hugo based sources for my personal blog. It's made with the [Congo theme](https://github.com/jpanther/congo). The static pages are served by the included caddy server with a custom config. The custom config is needed to redirect 404 errors to a custom page. This image contains the hugo based sources for my personal blog. It's made with the [Congo theme](https://github.com/jpanther/congo). The static pages are served by the included nginx server with a custom config. The custom config is needed to redirect 404 errors to a custom page.
You can simply run the container with `docker run -it --rm -p "8080:8080" ocram85/blog:latest` You can simply run the container with `docker run -it --rm -p "8080:80" ocram85/blog:latest`

Binary file not shown.

Before

Width:  |  Height:  |  Size: 784 KiB

After

Width:  |  Height:  |  Size: 86 KiB

62
docker-compose.yml Normal file
View File

@ -0,0 +1,62 @@
version: "3.8"
services:
next:
image: ocram85/blog:next
restart: unless-stopped
networks:
- blog
- traefik-public
deploy:
replicas: 1
update_config:
parallelism: 1
delay: 15s
order: start-first
labels:
- "traefik.enable=true"
#- "traefik.docker.lbswarm=true"
- "traefik.docker.network=traefik-public"
- "traefik.http.routers.next.rule=Host(`next.ocram85.com`)"
- "traefik.http.routers.next.tls=true"
- "traefik.http.services.next-srv.loadbalancer.server.port=80"
# optional health checks
- "traefik.http.services.next-srv.loadbalancer.healthCheck.path=/"
- "traefik.http.services.next-srv.loadbalancer.healthCheck.interval=10s"
- "traefik.http.services.next-srv.loadbalancer.healthCheck.timeout=3s"
- "traefik.http.services.next-srv.loadbalancer.healthCheck.port=80"
- "traefik.http.services.next-srv.loadbalancer.healthCheck.scheme=http"
blog:
image: ocram85/blog:latest
restart: unless-stopped
networks:
- blog
- traefik-public
deploy:
replicas: 2
update_config:
parallelism: 1
delay: 15s
order: start-first
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik-public"
#- "traefik.docker.lbswarm=true"
- "traefik.http.routers.blog.rule=Host(`ocram85.com`)"
- "traefik.http.routers.blog.tls=true"
- "traefik.http.services.blog-srv.loadbalancer.server.port=80"
# optional health checks
- "traefik.http.services.blog-srv.loadbalancer.healthCheck.path=/"
- "traefik.http.services.blog-srv.loadbalancer.healthCheck.interval=10s"
- "traefik.http.services.blog-srv.loadbalancer.healthCheck.timeout=3s"
- "traefik.http.services.blog-srv.loadbalancer.healthCheck.port=80"
- "traefik.http.services.blog-srv.loadbalancer.healthCheck.scheme=http"
networks:
traefik-public:
external: true
blog:
name: blog
driver: overlay

17
nginx.conf Normal file
View File

@ -0,0 +1,17 @@
events {
worker_connections 1024;
}
http {
include mime.types;
server {
listen 80;
root /usr/share/nignx/html;
index index.html;
error_page 404 /404.html;
location / {
try_files $uri $uri/ =404;
}
}
}