From 15cc46f3fe9947db331f1ed432f32addb3572977 Mon Sep 17 00:00:00 2001 From: theartcher Date: Mon, 15 Dec 2025 19:46:44 +0100 Subject: [PATCH 1/3] Create Dockerfile, update config file, update readme, initialize action --- .github/workflows/deploy.yml | 6 ++++++ Dockerfile | 29 +++++++++++++++++++++++++++++ README.md | 18 +++++++++++++++--- docusaurus.config.ts | 1 + 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5d15a0b..8d0b136 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -55,6 +55,12 @@ jobs: id: deployment uses: actions/deploy-pages@v4 + dockerhub-release: + # compile the docker image + # push to dockerhub + # log the url of the dockerhub repo here (https://hub.docker.com/repository/docker/theartcher/designpatternpedia) + name: Compile and Push Docker Image + lighthouse: name: Lighthouse needs: deploy diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a71f70e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +# Build using the guide https://docusaurus.community/knowledge/deployment/docker/?target=dev + +# Stage 1: Base image. +## Start with a base image containing NodeJS so we can build Docusaurus. +FROM node:lts AS base +## Disable colour output from yarn to make logs easier to read. +ENV FORCE_COLOR=0 +## Enable corepack. +RUN corepack enable +## Set the working directory to `/opt/docusaurus`. +WORKDIR /opt/docusaurus + +# Stage 2: Production build mode. +FROM base AS prod +## Set the working directory to `/opt/docusaurus`. +WORKDIR /opt/docusaurus +## Copy over the source code. +COPY . /opt/docusaurus/ +## Install dependencies with `--immutable` to ensure reproducibility. +RUN npm ci +## Build the static site. +RUN npm run build + +# Stage 3: Serve with `docusaurus serve`. +FROM prod AS serve +## Expose the port that Docusaurus will run on. +EXPOSE 3000 +## Run the production server. +CMD ["npm", "run", "serve", "--", "--host", "0.0.0.0", "--no-open"] \ No newline at end of file diff --git a/README.md b/README.md index 1a0b14e..813b410 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ - [Build and serve](#build-and-serve) - [Deployment](#deployment) - [GitHub Pages](#github-pages) - - [Docker Image](#docker-image) + - [Docker](#docker) - [Contributing](#contributing) This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator. @@ -84,9 +84,21 @@ This step is only necessary when you want to differ from the default `baseUrl` v T.B.A -### Docker Image +### Docker -T.B.A +The [Dockerfile](./Dockerfile) can be found in the root directory of the project. To build the Docker image _locally_, run the following command: + +```bash +docker build . -t designpatternpedia +``` + +To then run the Docker image _locally_, use the following command: + +```bash +docker run -p 3000:3000 designpatternpedia +``` + +The compiled image can be found on [Docker Hub at 'theartcher/designpatternpedia'](https://hub.docker.com/repository/docker/theartcher/designpatternpedia). ## Contributing diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 3b7f452..c5883ab 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -58,6 +58,7 @@ const config: Config = { "@docusaurus/theme-mermaid", ], themeConfig: { + indexBlog: false, // Replace with your project's social card image: "img/docusaurus-social-card.jpg", colorMode: { From 02678a1b780bcf455ca1e0bdb3df27f313e1223a Mon Sep 17 00:00:00 2001 From: theartcher Date: Mon, 15 Dec 2025 20:10:13 +0100 Subject: [PATCH 2/3] Finish deploy step --- .github/workflows/deploy.yml | 41 +++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 8d0b136..74e3370 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -56,10 +56,45 @@ jobs: uses: actions/deploy-pages@v4 dockerhub-release: - # compile the docker image - # push to dockerhub - # log the url of the dockerhub repo here (https://hub.docker.com/repository/docker/theartcher/designpatternpedia) name: Compile and Push Docker Image + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + attestations: write + id-token: write + steps: + - name: Check out the repo + uses: actions/checkout@v5 + + - name: Log in to Docker Hub + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ secrets.DOCKER_USERNAME }}/designpatternpedia + + - name: Build and push Docker image + id: push + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v3 + with: + subject-name: index.docker.io/${{ secrets.DOCKER_USERNAME }}/designpatternpedia + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true lighthouse: name: Lighthouse From 3fed4337e8c647d9844d0c28969e9bee39b6109a Mon Sep 17 00:00:00 2001 From: theartcher Date: Mon, 15 Dec 2025 20:22:53 +0100 Subject: [PATCH 3/3] Moved property to correct object --- docusaurus.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus.config.ts b/docusaurus.config.ts index c5883ab..a28d9d5 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -53,12 +53,12 @@ const config: Config = { hashed: true, indexDocs: true, indexPages: true, + indexBlog: false, }, ], "@docusaurus/theme-mermaid", ], themeConfig: { - indexBlog: false, // Replace with your project's social card image: "img/docusaurus-social-card.jpg", colorMode: {