Skip to content

Commit

Permalink
Update npm & add docker build + CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyreum committed Jul 14, 2024
1 parent 5dd910d commit 0de3394
Show file tree
Hide file tree
Showing 13 changed files with 24,801 additions and 19,085 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build release Docker image

on:
# Trigger the action manually from the UI
workflow_dispatch:
# Trigger the action when I create or push a `master` branch
push:
branches:
- 'master'

env:
DOCKER_IMAGE_NAME: erethon-docs
DOCKER_REGISTRY_URL: ${{ secrets.PRIVATE_REGISTRY_URL }}

jobs:
build_docker_images:
# Job name that shows in the GitHub UI
name: Build Docker Images
# Runner to use
runs-on: ubuntu-latest

steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.PRIVATE_REGISTRY_URL }}
username: ${{ secrets.PRIVATE_REGISTRY_USERNAME }}
password: ${{ secrets.PRIVATE_REGISTRY_PASSWORD }}
- name: Checkout
uses: actions/checkout@v3

# Build the Docker image
- name: Build the Docker image
run: docker build . --file Dockerfile --tag $DOCKER_IMAGE_NAME:latest

# Tag the image
- name: Create a latest image as well
run: docker tag $DOCKER_IMAGE_NAME:latest $DOCKER_REGISTRY_URL/$DOCKER_IMAGE_NAME:latest

# Push the image to the registry
- name: Push the Docker image with version number
run: docker push $DOCKER_REGISTRY_URL/$DOCKER_IMAGE_NAME:latest

# Remove the local images
- name: Remove the Docker image with version number
run: docker rmi $DOCKER_REGISTRY_URL/$DOCKER_IMAGE_NAME:latest

- name: Remove the local image
run: docker rmi $DOCKER_IMAGE_NAME:latest

- name: Trigger Docker re-deployment
run: |
curl -H "Authorization: Bearer ${{ secrets.DEPLOYMENT_TOKEN }}" ${{ secrets.DEPLOYMENT_URL }}
45 changes: 45 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# syntax=docker/dockerfile:1

# 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 2a: Development mode.
FROM base as dev
## Set the working directory to `/opt/docusaurus`.
WORKDIR /opt/docusaurus
## Expose the port that Docusaurus will run on.
EXPOSE 3000
## Run the development server.
CMD [ -d "node_modules" ] && npm run start --host 0.0.0.0 --poll 1000 || npm run install && npm run start --host 0.0.0.0 --poll 1000

# Stage 2b: 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 3a: 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"]

# Stage 3b: Serve with Caddy.
FROM caddy:2-alpine as caddy
## Copy the Caddyfile.
COPY --from=prod /opt/docusaurus/Caddyfile /etc/caddy/Caddyfile
## Copy the Docusaurus build output.
COPY --from=prod /opt/docusaurus/build /var/docusaurus
4 changes: 0 additions & 4 deletions docs/aergia/_category_.json

This file was deleted.

8 changes: 0 additions & 8 deletions docs/aergia/intro.md

This file was deleted.

10 changes: 0 additions & 10 deletions docs/aergia/placeholders.md

This file was deleted.

4 changes: 4 additions & 0 deletions docs/dreships/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "DREShips",
"position": 3
}
5 changes: 5 additions & 0 deletions docs/dreships/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Introduction
sidebar_position: 1
---

2 changes: 1 addition & 1 deletion docs/dungeonsxl/_category_.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"label": "DungeonsXL",
"position": 4
"position": 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Main Configuration
sidebar_position: 3
---

```
```yaml
# Main configuration of DungeonsXL (config.yml in DungeonsXL folder)

# Don't edit this one.
Expand Down
10 changes: 5 additions & 5 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion

const lightCodeTheme = require('prism-react-renderer/themes/github');
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
const lightCodeTheme = require('prism-react-renderer/themes/vsDark');
const darkCodeTheme = require('prism-react-renderer/themes/vsDark');

/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Erethon Docs',
tagline: 'Official Erethon documentation',
url: 'https://erethon.de',
baseUrl: '/',
baseUrl: '/docs/',
onBrokenLinks: 'warn',
onBrokenMarkdownLinks: 'warn',
favicon: 'img/favicon.ico',
Expand Down Expand Up @@ -76,9 +76,9 @@ const config = {
},
{
type: 'doc',
docId: 'aergia/intro',
docId: 'dreships/intro',
position: 'left',
label: 'Aergia',
label: 'DREShips',
},
{
type: 'doc',
Expand Down
Loading

0 comments on commit 0de3394

Please sign in to comment.