From 782d9e6d1909a44829e773368f47784eb3baba53 Mon Sep 17 00:00:00 2001 From: CrimsonTome Date: Sun, 19 Mar 2023 14:57:13 +0000 Subject: [PATCH 1/4] feat: add Dockerfile --- Dockerfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a58e702 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM node:18.14-alpine3.16 as npmpackages +WORKDIR /app +COPY package.json . +RUN npm install + +FROM node:18.14-alpine3.16 as builder +WORKDIR /app +COPY --from=npmpackages /app /app +COPY . . +RUN npm run build + +FROM nginx:1.17.10-alpine +RUN rm -r /usr/share/nginx/html/ +COPY --from=builder /app/_site/ /usr/share/nginx/html From e3b044ad95e28ef28d465e1b5ceaeba9a49a4f6d Mon Sep 17 00:00:00 2001 From: CrimsonTome Date: Sun, 19 Mar 2023 15:10:09 +0000 Subject: [PATCH 2/4] feat: add docker publish action --- .github/workflows/docker-publish.yml | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..b54ee2b --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,52 @@ + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Publish Docker image + +on: + push: + branches: + - "main" + +jobs: + push_to_registries: + name: Push Docker image to multiple registries + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: | + ${{ secrets.DOCKERHUB_USERNAME }}/hullblogs + ghcr.io/${{ github.repository }} + + - name: Build and push Docker images + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From 5301883205bb02d1831ea3d274524e27aff444f3 Mon Sep 17 00:00:00 2001 From: CrimsonTome Date: Sun, 19 Mar 2023 15:29:12 +0000 Subject: [PATCH 3/4] docs: add docs on Docker --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 700a92a..1ff20a3 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ For development (and production, if you're in charge of the hullblogs.com websit ## System (and user) Requirements - [Node.js](https://nodejs.org/) + - [Docker](https://www.docker.com/)(optional) - A text editor (for editing `feeds.json`) - A web browser (we recommend [Firefox](https://firefox.com/)) - Basic knowledge of the Linux Terminal (or Windows Command Line) @@ -106,6 +107,18 @@ If you're debugging the feed compatibility code, then setting the `DEBUG_FEEDITE If you're working on the CSS, note that Eleventy will *not* auto-rebuild & reload the browser. For that, you need to re-save a file it *does* watch, such as `index.html`, `.eleventy.js`, etc (even if you haven't made any changes). +### Getting Started with Docker + +Clone the repo as above and `cd` into it. The Dockerfile can be found [here](Dockerfile) +``` +sudo docker build -t hullblogs . # builds the container +sudo docker run -itdp unused-port-number:80 hullblogs # runs the site on a port that is available +# visit localhost:port or ip:port if you are hosting on a VPS and the site should be available to view +``` +If you don't want to clone the repo and *just* want to run the site you can do `sudo docker run -itdp unused-port-number:80 crimsontome427/hullblogs` + +Using a tool like [Ouroboros](https://github.com/gmt2001/ouroboros) you can automatically update the container without the need for a rebuild each time, this can only be done if Ouroboros can see your container in a registry. + ### Environment Variables The following environment variables can be used to influence the behaviour of the aggregator. From 06acd19f7bbc3a34d410dbdac7f180887eab6270 Mon Sep 17 00:00:00 2001 From: CTome <64846840+CrimsonTome@users.noreply.github.com> Date: Mon, 20 Mar 2023 15:07:06 +0000 Subject: [PATCH 4/4] append :main to docker docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ff20a3..379b6f1 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ sudo docker build -t hullblogs . # builds the container sudo docker run -itdp unused-port-number:80 hullblogs # runs the site on a port that is available # visit localhost:port or ip:port if you are hosting on a VPS and the site should be available to view ``` -If you don't want to clone the repo and *just* want to run the site you can do `sudo docker run -itdp unused-port-number:80 crimsontome427/hullblogs` +If you don't want to clone the repo and *just* want to run the site you can do `sudo docker run -itdp unused-port-number:80 crimsontome427/hullblogs:main` Using a tool like [Ouroboros](https://github.com/gmt2001/ouroboros) you can automatically update the container without the need for a rebuild each time, this can only be done if Ouroboros can see your container in a registry.