Skip to content

Commit

Permalink
Add files for github actions, docker compose, dockerfile (#22)
Browse files Browse the repository at this point in the history
Co-authored-by: madebytimo <t.schnaible@madebytimo.de>
  • Loading branch information
maexled and madebyTimo committed Apr 8, 2023
1 parent e7daaf0 commit 6ac9617
Show file tree
Hide file tree
Showing 12 changed files with 675 additions and 1 deletion.
45 changes: 45 additions & 0 deletions .github/workflows/deploy-development-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Create and publish development Docker image

on:
push:
branches-ignore:
- "main"
workflow_dispatch:

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

jobs:
build-and-push-image:
runs-on: self-hosted
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: type=raw,value=development

- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
53 changes: 53 additions & 0 deletions .github/workflows/deploy-docker-image-on-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

name: Create and publish a Docker image on Release

on:
push:
branches:
- "main"
tags:
- "v*"
pull_request:
branches:
- "main"

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

jobs:
test:
uses: ./.github/workflows/test.yml

build-and-push-image:
runs-on: self-hosted
needs: [test]
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
45 changes: 45 additions & 0 deletions .nginx/compose/nginx-dev-e2e.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
server {
listen 80;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;

location / {
proxy_pass http://landing-page/;
}

location /keycloak/ {
proxy_pass http://keycloak/keycloak/;
}

location /overworld/api/ {
proxy_pass http://overworld-backend/api/;
}

location /minigames/memory/api/ {
proxy_pass http://host.docker.internal:8080/api/;
}

location /overworld/ {
proxy_pass http://overworld/;
}

location /minigames/memory/ {
proxy_pass http://host.docker.internal:8000/minigames/memory/;
}

location /lecturer-interface/ {
proxy_pass http://lecturer-interface/;
}

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
45 changes: 45 additions & 0 deletions .nginx/compose/nginx-dev.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
server {
listen 80;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;

location / {
proxy_pass http://landing-page/;
}

location /keycloak/ {
proxy_pass http://keycloak/keycloak/;
}

location /overworld/api/ {
proxy_pass http://overworld-backend/api/;
}

location /minigames/memory/api/ {
proxy_pass http://memory-backend/api/;
}

location /overworld/ {
proxy_pass http://overworld/;
}

location /minigames/memory/ {
proxy_pass http://host.docker.internal:8000/minigames/memory/;
}

location /lecturer-interface/ {
proxy_pass http://lecturer-interface/;
}

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
45 changes: 45 additions & 0 deletions .nginx/compose/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
server {
listen 80;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;

location / {
proxy_pass http://landing-page/;
}

location /keycloak/ {
proxy_pass http://keycloak/keycloak/;
}

location /overworld/api/ {
proxy_pass http://overworld-backend/api/;
}

location /minigames/memory/api/ {
proxy_pass http://memory-backend/api/;
}

location /overworld/ {
proxy_pass http://overworld/;
}

location /minigames/memory/ {
proxy_pass http://memory/;
}

location /lecturer-interface/ {
proxy_pass http://lecturer-interface/;
}

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
18 changes: 18 additions & 0 deletions .nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
worker_processes 4;

events { worker_connections 1024; }

http {
server {
listen 80;
server_name memory;
root /usr/share/nginx/html;
include /etc/nginx/mime.types;

rewrite ^/memory/(.*)$ /$1 last;

location / {
try_files $uri /index.html;
}
}
}
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM node:17-alpine as builder

WORKDIR /vue-ui

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

# Copy rest of the files
COPY . .

# Build the project
RUN npm run build

FROM nginx:alpine as production-build
COPY ./.nginx/nginx.conf /etc/nginx/nginx.conf

## Remove default nginx index page
RUN rm -rf /usr/share/nginx/html/*

# Copy from the stahg 1
COPY --from=builder /vue-ui/dist /usr/share/nginx/html

EXPOSE 80/tcp
Loading

0 comments on commit 6ac9617

Please sign in to comment.