Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test version management fix and embed #116

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c756abc
Add embed option to share modal
farisd16 Sep 14, 2024
4447d43
Adjust share modal
farisd16 Sep 16, 2024
a6a7d86
Adjust embedding link
farisd16 Sep 19, 2024
206c993
Fix typo in embedding link
farisd16 Sep 19, 2024
8dd4236
Adjust content type to fix embedding not being displayed
farisd16 Sep 26, 2024
5bd0204
Make UI change for deployment debugging
farisd16 Sep 29, 2024
313bf53
Add white background to svg
farisd16 Oct 3, 2024
18223c9
Remove change for debugging purposes
farisd16 Oct 3, 2024
10f226e
Merge remote-tracking branch 'origin/main' into feature/embed-diagram
farisd16 Nov 22, 2024
4aef016
Adjust README
farisd16 Nov 22, 2024
1898c98
Fix disappearing versions
farisd16 Nov 25, 2024
bd219b7
Attempt to fix bamboo
farisd16 Nov 28, 2024
b52864b
Attempt to fix bamboo
farisd16 Nov 28, 2024
d4fdf2b
create prod compose
FelixTJDietrich Nov 29, 2024
380a397
add workflows
FelixTJDietrich Nov 29, 2024
5dda4dd
add deploy workflow
FelixTJDietrich Nov 29, 2024
8deb3c7
change port
FelixTJDietrich Nov 29, 2024
1255314
Merge branch 'main' into bugfix/disappearing-versions
FelixTJDietrich Nov 29, 2024
027fd16
Format README, remove trailing backslash from example DEPLOYMENT_URL
farisd16 Nov 30, 2024
d90fa08
modify workflow
FelixTJDietrich Dec 2, 2024
81b9ee2
fix image name
FelixTJDietrich Dec 2, 2024
63b5930
yolo
FelixTJDietrich Dec 2, 2024
f28b3ad
fix error
FelixTJDietrich Dec 2, 2024
b7be687
remove needed file
FelixTJDietrich Dec 2, 2024
4aa9d1e
update
FelixTJDietrich Dec 2, 2024
a6887d7
fix compose file
FelixTJDietrich Dec 2, 2024
f6757fd
fix casing
FelixTJDietrich Dec 2, 2024
1f70b29
remove cache
FelixTJDietrich Dec 2, 2024
a7ef550
map to host
FelixTJDietrich Dec 2, 2024
a633da3
fix redis
FelixTJDietrich Dec 2, 2024
6d914c4
remove arg
FelixTJDietrich Dec 3, 2024
afac92f
fix deployment url
FelixTJDietrich Dec 3, 2024
f1da6b5
fix sed
FelixTJDietrich Dec 3, 2024
e82c13c
fix url
FelixTJDietrich Dec 3, 2024
c913bce
Merge remote-tracking branch 'origin/bugfix/disappearing-versions' in…
FelixTJDietrich Dec 3, 2024
6de62b0
Merge remote-tracking branch 'origin/feature/embed-diagram' into chor…
FelixTJDietrich Dec 3, 2024
33cce30
Trigger Build
FelixTJDietrich Dec 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .github/workflows/build-and-push-tmp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Move to ls1intum/.github/.github/workflows/build-and-push-docker-image.yml@main in the future
name: Build and Push Docker Image

on:
workflow_call:
inputs:
image-name:
type: string
default: ${{ github.repository }}
description: "The name for the docker image (Default: Repository name)"
docker-file:
type: string
default: Dockerfile
description: "The path to the Dockerfile (Default: ./Dockerfile)"
docker-context:
type: string
default: .
description: "The context for the Docker build (Default: .)"
build-args:
type: string
description: "List of additional build contexts (e.g., name=path)"
required: false
platforms:
type: string
description: "List of platforms for which to build the image"
default: linux/amd64,linux/arm64
registry:
type: string
default: ghcr.io
description: "The registry to push the image to (Default: ghcr.io)"

secrets:
registry-user:
required: false
registry-password:
required: false

outputs:
image-tag:
description: "The tag of the pushed image"
value: ${{ jobs.build.outputs.image-tag }}
jobs:
build:
name: Build Docker Image for ${{ inputs.image-name }}
runs-on: ubuntu-latest
outputs:
image-tag: ${{ steps.set-tag.outputs.image-tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Install Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ secrets.registry-user || github.actor }}
password: ${{ secrets.registry-password || secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.registry }}/${{ inputs.image-name }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=ref,event=pr

- name: Set image tag output
id: set-tag
run: echo "::set-output name=image-tag::${{ steps.meta.outputs.version }}"

- name: Build and push Docker Image
uses: docker/build-push-action@v6
with:
context: ${{ inputs.docker-context }}
file: ${{ inputs.docker-file }}
platforms: ${{ inputs.platforms }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: ${{ inputs.build-args }}
push: true
18 changes: 18 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build Docker Image

on:
workflow_call:
outputs:
image-tag:
description: "The tag of the pushed image"
value: ${{ jobs.build-and-push-workflow.outputs.image-tag }}

jobs:
build-and-push-workflow:
name: Build and Push Docker Image
# uses: ls1intum/.github/.github/workflows/build-and-push-docker-image.yml@main
uses: ./.github/workflows/build-and-push-tmp.yml
with:
image-name: ls1intum/apollon_standalone
docker-file: Dockerfile.redis
secrets: inherit
103 changes: 103 additions & 0 deletions .github/workflows/deploy-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Deploy Docker Image

on:
workflow_call:
inputs:
environment:
required: true
type: string
image-name:
type: string
default: ${{ github.repository }}
description: "The name for the docker image (Default: Repository name)"
image-tag:
default: "latest"
type: string
description: "The tag for the docker image (Default: latest)"

jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.environment }}
url: 'https://${{ vars.SERVER_HOST }}'
steps:
- name: SSH to VM and Execute Docker-Compose Down (if exists)
uses: appleboy/[email protected]
with:
host: ${{ vars.VM_HOST }}
username: ${{ vars.VM_USERNAME }}
key: ${{ secrets.VM_SSH_PRIVATE_KEY }}
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }}
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }}
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
script: |
#!/bin/bash
set -e # Exit immediately if a command exits with a non-zero status

COMPOSE_FILE="docker-compose.prod.yml"
ENV_FILE=".env.prod"

# Check if docker-compose.prod.yml exists
if [ -f "$COMPOSE_FILE" ]; then
echo "$COMPOSE_FILE found."

# Check if .env.prod exists
if [ -f "$ENV_FILE" ]; then
docker compose -f "$COMPOSE_FILE" --env-file="$ENV_FILE" down --remove-orphans --rmi all
else
docker compose -f "$COMPOSE_FILE" down --remove-orphans --rmi all
fi
else
echo "$COMPOSE_FILE does not exist. Skipping docker compose down."
fi

- name: checkout
uses: actions/checkout@v4

- name: Copy Docker Compose File From Repo to VM Host
uses: appleboy/[email protected]
with:
host: ${{ vars.VM_HOST }}
username: ${{ vars.VM_USERNAME }}
key: ${{ secrets.VM_SSH_PRIVATE_KEY }}
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }}
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }}
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
source: "./docker-compose.prod.yml"
target: /home/${{ vars.VM_USERNAME }}

- name: SSH to VM and create .env.prod file
uses: appleboy/[email protected]
with:
host: ${{ vars.VM_HOST }}
username: ${{ vars.VM_USERNAME }}
key: ${{ secrets.VM_SSH_PRIVATE_KEY }}
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }}
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }}
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
script: |
touch .env.prod

echo "ENVIRONMENT=${{ vars.ENVIRONMENT }}" > .env.prod

echo "DEPLOYMENT_URL=${{ vars.DEPLOYMENT_URL }}" > .env.prod
echo "APOLLON_REDIS_DIAGRAM_TTL=${{ vars.APOLLON_REDIS_DIAGRAM_TTL }}" >> .env.prod

echo "IMAGE_TAG=${{ inputs.image-tag }}" >> .env.prod

- name: SSH to VM and Execute Docker-Compose Up
uses: appleboy/[email protected]
with:
host: ${{ vars.VM_HOST }}
username: ${{ vars.VM_USERNAME }}
key: ${{ secrets.VM_SSH_PRIVATE_KEY }}
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }}
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }}
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
script: |
docker compose -f docker-compose.prod.yml --env-file=.env.prod up --pull=always -d
18 changes: 18 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build and Deploy to Dev

on:
pull_request:
branches: [main]

jobs:
build-dev-container:
uses: ./.github/workflows/build-and-push.yml
secrets: inherit
deploy-dev-container:
needs: build-dev-container
uses: ./.github/workflows/deploy-docker.yml
secrets: inherit
with:
environment: Dev
image-name: ls1intum/apollon_standalone
image-tag: "${{ needs.build-dev-container.outputs.image-tag }}"
8 changes: 3 additions & 5 deletions Dockerfile.redis
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ RUN apk add --no-cache \
pango-dev \
giflib-dev


ARG DEPLOYMENT_URL="http://localhost:8080"

ENV APOLLON_REDIS_URL=""
ENV DEPLOYMENT_URL=${DEPLOYMENT_URL}
ENV DEPLOYMENT_URL="http://localhost:8080"
ENV APOLLON_REDIS_URL="redis://localhost:6379"
ENV APOLLON_REDIS_DIAGRAM_TTL="30d"

WORKDIR /app

Expand Down
Loading
Loading