Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Add Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesu committed Mar 7, 2024
1 parent 191d362 commit 9fff55f
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM node:14-alpine

WORKDIR /usr/src/app

# Copy and install dependencies
COPY package*.json ./
RUN npm ci

# Bundle app source
COPY . .

# Build frontend
RUN npm run build

# Use pm2 to run app
RUN npm i -g pm2

ENV NODE_ENV=production

# Configuration
RUN mkdir /config
ENV CONFIG_FILE=/config/config.json

CMD pm2-runtime ecosystem.config.json
45 changes: 45 additions & 0 deletions .docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# [coli-rich](https://github.com/gbv/coli-rich) (Docker)

This project is part of a larger infrastructure of [Project coli-conc](https://coli-conc.gbv.de). See [GitHub](https://github.com/gbv/coli-rich) for more information about the tool.

## Supported Architectures
Currently, only `x86-64` is supported.

## Available Tags
- The current release version is available under `latest`. The project is not yet stable, however. Once it is stable, we will offer SemVer versions and recommend to use version tags for deployment. <!-- However, new major versions might break compatibility of the previously used config file, therefore it is recommended to use a version tag instead. -->
<!-- - We follow SemVer for versioning the application. Therefore, `x` offers the latest image for the major version x, `x.y` offers the latest image for the minor version x.y, and `x.y.z` offers the image for a specific patch version x.y.z. -->
- Additionally, the latest development version is available under `dev`.

## Usage
It is recommended to run the image using [Docker Compose](https://docs.docker.com/compose/). Note that depending on your system, it might be necessary to use `sudo docker compose`. For older Docker versions, use `docker-compose` instead of `docker compose`.

1. Create `docker-compose.yml`:

```yml
version: "3"

services:
coli-rich:
image: ghcr.io/gbv/coli-rich
# volumes:
# - ./config.json:/config/config.json
ports:
- 3077:3077
restart: unless-stopped
```
2. Start the application:
```bash
docker compose up -d
```

This will create and start a coli-rich container running under host (and guest) port 3077. See [Configuration](#configuration) on how to configure it.

You can now access the application under `http://localhost:3077`.

## Application Setup
After changing `docker-compose.yml` (e.g. adjusting environment variables), it is necessary to recreate the container to apply changes: `docker compose up -d`. Changing the configuration file requires a restart: `docker compose restart`.

### Configuration
You can mount a config file into `/config/config.json` to configure coli-rich. Please refer to the [main documentation](../README.md#configuration) as well as to the [default configuration](../config/config.default.json) for more information and all available options.
12 changes: 12 additions & 0 deletions .docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3"

services:
coli-rich:
build:
context: ..
dockerfile: .docker/Dockerfile
volumes:
- ../config/config.json:/config/config.json
ports:
- 3077:3077
restart: unless-stopped
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
dist/
config/config.json
.env
.docker/data*
63 changes: 63 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Publish Docker
on:
push:
branches:
- main
- dev
tags:
- v*
paths:
- docker/Dockerfile
- config/**
- data/**
- src/**
- static/**
- views/**
- vue/**
- package*.json
- server.js
- index.html

# Adapted from:
# - https://github.com/docker/metadata-action#semver
# - https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
publish:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Docker Meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and Push
uses: docker/build-push-action@v4
with:
context: .
file: .docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 14.x ]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build
- run: npm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ config*.json
.env
node_modules/
dist
docker/data

0 comments on commit 9fff55f

Please sign in to comment.