Merge pull request #15 from CrimsonTome/main

feat: add Dockerfile
pull/3/head
Starbeamrainbowlabs 2023-04-17 21:15:02 +01:00 committed by GitHub
commit 244ebe130d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 79 additions and 0 deletions

52
.github/workflows/docker-publish.yml vendored Normal file
View File

@ -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 }}

14
Dockerfile Normal file
View File

@ -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

View File

@ -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: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.
### Environment Variables
The following environment variables can be used to influence the behaviour of the aggregator.