To create static files to serve in production, run
1$ hugo
and notice all the new static files that were generated in /public
Start with a popular, stable Nginx container
1$ docker pull nginx:alpine
Start up an nginx:alpine container:
1$ docker run -it <image id>
1$ docker cp <container name or image id>:/etc/nginx/conf.d/default.conf ~/
1$ docker exec -it <image name or id> sh
2$ cd /etc/nginx
1# under location / block:
2location /health {
3 access_log off;
4 return 200 'OK';
5}
Create this Dockerfile
1# Dockerfile
2
3FROM nginx:alpine
4
5# Copy static site files to the Nginx document root
6COPY ./public/. /usr/share/nginx/html
7
8# Copy custom nginx.conf with healthcheck to the container
9COPY nginx.conf /etc/nginx/conf.d/default.conf
10
11# Expose port 80
12EXPOSE 80
13
14# Command to start Nginx
15CMD ["nginx", "-g", "daemon off;"]
Build our image. Note that we’re using buildx, and passing in a platform, because my Fargate setup expects x86 images, and I am building with a Mac Air M1:
docker buildx build –platform linux/amd64 -t ..
docker push