Welcome to the Forrest

An environmental friendly repository which we use as an example to containerise a static website (Part I with Docker).

Part I, here we use docker to containerize our static website, so we can test it thoroughly before we go live.

You can find the repository on GitHub.

In this example we use a Docker.file to build our own image, the contents of the docker file looks like his:

FROM docker.io/library/alpine:latest
LABEL "copyright"="&copy 2023 Philip aka RobertoTorino"
LABEL version="1.0"
LABEL description="forrestgreen"
COPY . /etc/nginx/html
EXPOSE 80/tcp
RUN apk update && apk add nginx && apk add nano && mkdir -p /run/nginx && apk add curl shadow bind-tools tcpdump
COPY nginx/nginx.conf /etc/nginx
CMD ["nginx", "-g", "daemon off;"]
HEALTHCHECK --interval=1m --timeout=3s CMD curl -f http://localhost/ || exit 1

I used an Alpine Linux image here because of its small footprint compared to all other distros. But from what I read around the Globe it has some drawbacks which prevent devs from using Alpine Linux in production environments. The most heard drawback is the DNS resolver issues. These issues are due to a bug in musl.

Place the Docker.file in the root of your project with this content (of course you can adjust everything to your settings).

What it does:

  • It pulls the latest alpine image from Docker

  • Adds some labels to the image.

  • Copies all files and dir to /etc/nginx/html.

  • Copies the Nginx.conf file to /etc/nginx.

  • Updates all packages and installs Nginx, Nano text editor and Curl bind-tools tcpdump.

  • Start Nginx in the foreground (daemon off) and set the global configuration for this (-g).

  • Performs a health check.

This is what we need to build the environment, in your terminal type:

docker build -t forrestgreen:latest -f Dockerfile .

Wait until the process finishes then type:

docker run -p 80:80 forrestgreen:latest

If this is finished run your application with: or localhost:80

Showcase of this process (YouTube video), click on the picture.