From d4fdf2b3468d6c64e05d5d1aa453e2d7f20da3de Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Fri, 29 Nov 2024 10:25:48 +0100 Subject: [PATCH 01/24] create prod compose --- Dockerfile.redis | 3 ++- docker-compose.prod.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 docker-compose.prod.yml diff --git a/Dockerfile.redis b/Dockerfile.redis index 09d8f44c..8c6a997d 100644 --- a/Dockerfile.redis +++ b/Dockerfile.redis @@ -8,9 +8,10 @@ RUN apk add --no-cache \ giflib-dev +ARG APOLLON_REDIS_URL="redis://localhost:6379" ARG DEPLOYMENT_URL="http://localhost:8080" -ENV APOLLON_REDIS_URL="" +ENV APOLLON_REDIS_URL=${APOLLON_REDIS_URL} ENV DEPLOYMENT_URL=${DEPLOYMENT_URL} WORKDIR /app diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 00000000..69e0c971 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,40 @@ +version: '3.8' + +services: + redis: + image: redis/redis-stack-server:7.4.0-v1 + container_name: apollon-redis + volumes: + - ./redis_data:/data + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 5s + timeout: 5s + retries: 5 + restart: unless-stopped + networks: + - apollon-network + + apollon_standalone: + build: + context: . + dockerfile: Dockerfile.redis + args: + - DEPLOYMENT_URL=${DEPLOYMENT_URL} + container_name: apollon-standalone + environment: + - APOLLON_REDIS_URL=redis://apollon_redis:6379 + - APOLLON_REDIS_DIAGRAM_TTL=${APOLLON_REDIS_DIAGRAM_TTL} + - DEPLOYMENT_URL=${DEPLOYMENT_URL} + restart: unless-stopped + expose: + - "8080" + depends_on: + redis: + condition: service_healthy + networks: + - apollon-network + +networks: + apollon-network: + driver: bridge From 380a3977a1338dce6d7c1f904070788d26681fa2 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Fri, 29 Nov 2024 10:44:21 +0100 Subject: [PATCH 02/24] add workflows --- .github/workflows/build-and-push-docker.yml | 75 +++++++++++++++++++++ .github/workflows/dev.yml | 17 +++++ 2 files changed, 92 insertions(+) create mode 100644 .github/workflows/build-and-push-docker.yml create mode 100644 .github/workflows/dev.yml diff --git a/.github/workflows/build-and-push-docker.yml b/.github/workflows/build-and-push-docker.yml new file mode 100644 index 00000000..67325cb7 --- /dev/null +++ b/.github/workflows/build-and-push-docker.yml @@ -0,0 +1,75 @@ +name: Build Docker Image + +on: + workflow_call: + outputs: + apollon_standalone_image_tag: + description: "The tag of the apollon standalone image that was built" + value: ${{ jobs.build.outputs.apollon_standalone_image_tag }} + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - dockerfile: ./Dockerfile.redis + image: ghcr.io/ls1intum/Apollon_standalone/apollon-standalone + context: . + path: apollon-standalone + outputs: + apollon_standalone_image_tag: "${{ steps.output-tag-apollon-standalone.outputs.apollon_standalone_image_tag }}" + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v44 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: all + + - name: Install Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ matrix.image }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=ref,event=branch + type=ref,event=pr + + - name: Build and push Docker Image + uses: docker/build-push-action@v5 + with: + context: ${{ matrix.context }} + file: ${{ matrix.dockerfile }} + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + + - id: output-tag-apollon-standalone + run: | + if [[ "${{ matrix.path }}" == "apollon-standalone" ]] && [[ "${{ steps.changed-files.outputs.any_changed }}" == "true" ]]; then + echo "apollon_standalone_image_tag=${{ steps.meta.outputs.version }}" >> "$GITHUB_OUTPUT" + elif [[ "${{ matrix.path }}" == "server" ]]; then + echo "apollon_standalone_image_tag=latest" >> "$GITHUB_OUTPUT" + fi \ No newline at end of file diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 00000000..334df0f6 --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,17 @@ +name: Build and Deploy to Dev + +on: + pull_request: + +jobs: + build-dev-container: + uses: ./.github/workflows/build-and-push-docker.yml + secrets: inherit + # deploy-dev-container: + # needs: build-dev-container + # uses: ./.github/workflows/deploy_docker.yml + # secrets: inherit + # with: + # environment: Dev + # server_image_tag: "${{ needs.build-dev-container.outputs.server_image_tag }}" + # client_image_tag: "${{ needs.build-dev-container.outputs.client_image_tag }}" \ No newline at end of file From 5dda4dd4accd487e5dcc708b40b5d5ac94110ce1 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Fri, 29 Nov 2024 11:15:42 +0100 Subject: [PATCH 03/24] add deploy workflow --- .github/workflows/deploy-docker.yml | 80 +++++++++++++++++++++++++++++ .github/workflows/dev.yml | 15 +++--- Dockerfile.redis | 6 ++- docker-compose.prod.yml | 6 +-- 4 files changed, 92 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/deploy-docker.yml diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/deploy-docker.yml new file mode 100644 index 00000000..d3a917c5 --- /dev/null +++ b/.github/workflows/deploy-docker.yml @@ -0,0 +1,80 @@ +name: Deploy Docker Image + +on: + workflow_call: + inputs: + environment: + required: true + type: string + apollon_standalone_image_tag: + default: "latest" + type: string + +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 + uses: appleboy/ssh-action@v1.0.3 + 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 down --remove-orphans --rmi all + + - name: checkout + uses: actions/checkout@v4 + + - name: Copy Docker Compose File From Repo to VM Host + uses: appleboy/scp-action@v0.1.7 + 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/ssh-action@v1.0.3 + 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 "APOLLON_STANDALONE_IMAGE_TAG=${{ inputs.apollon_standalone_image_tag }}" >> .env.prod + + - name: SSH to VM and Execute Docker-Compose Up + uses: appleboy/ssh-action@v1.0.3 + 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 \ No newline at end of file diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 334df0f6..b51025e4 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -7,11 +7,10 @@ jobs: build-dev-container: uses: ./.github/workflows/build-and-push-docker.yml secrets: inherit - # deploy-dev-container: - # needs: build-dev-container - # uses: ./.github/workflows/deploy_docker.yml - # secrets: inherit - # with: - # environment: Dev - # server_image_tag: "${{ needs.build-dev-container.outputs.server_image_tag }}" - # client_image_tag: "${{ needs.build-dev-container.outputs.client_image_tag }}" \ No newline at end of file + deploy-dev-container: + needs: build-dev-container + uses: ./.github/workflows/deploy-docker.yml + secrets: inherit + with: + environment: Dev + apollon_standalone_image_tag: "${{ needs.build-dev-container.outputs.apollon_standalone_image_tag }}" \ No newline at end of file diff --git a/Dockerfile.redis b/Dockerfile.redis index 8c6a997d..9ccec61d 100644 --- a/Dockerfile.redis +++ b/Dockerfile.redis @@ -8,11 +8,13 @@ RUN apk add --no-cache \ giflib-dev -ARG APOLLON_REDIS_URL="redis://localhost:6379" ARG DEPLOYMENT_URL="http://localhost:8080" +ARG APOLLON_REDIS_URL="redis://localhost:6379" +ARG APOLLON_REDIS_DIAGRAM_TTL=3600 -ENV APOLLON_REDIS_URL=${APOLLON_REDIS_URL} ENV DEPLOYMENT_URL=${DEPLOYMENT_URL} +ENV APOLLON_REDIS_URL=${APOLLON_REDIS_URL} +ENV APOLLON_REDIS_DIAGRAM_TTL=${APOLLON_REDIS_DIAGRAM_TTL} WORKDIR /app diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 69e0c971..060e2e3a 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -16,11 +16,7 @@ services: - apollon-network apollon_standalone: - build: - context: . - dockerfile: Dockerfile.redis - args: - - DEPLOYMENT_URL=${DEPLOYMENT_URL} + image: "ghcr.io/ls1intum/Apollon_standalone/apollon-standalone:${APOLLON_STANDALONE_IMAGE_TAG}" container_name: apollon-standalone environment: - APOLLON_REDIS_URL=redis://apollon_redis:6379 From 8deb3c72c7d0080a49268716a92ba003d28f8dae Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Fri, 29 Nov 2024 19:00:13 +0100 Subject: [PATCH 04/24] change port --- Dockerfile.redis | 2 +- README.md | 2 +- packages/webapp/webpack/webpack.common.js | 2 +- packages/webapp/webpack/webpack.dev.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile.redis b/Dockerfile.redis index 9ccec61d..e3b0bd49 100644 --- a/Dockerfile.redis +++ b/Dockerfile.redis @@ -10,7 +10,7 @@ RUN apk add --no-cache \ ARG DEPLOYMENT_URL="http://localhost:8080" ARG APOLLON_REDIS_URL="redis://localhost:6379" -ARG APOLLON_REDIS_DIAGRAM_TTL=3600 +ARG APOLLON_REDIS_DIAGRAM_TTL="30d" ENV DEPLOYMENT_URL=${DEPLOYMENT_URL} ENV APOLLON_REDIS_URL=${APOLLON_REDIS_URL} diff --git a/README.md b/README.md index 77ff7509..a575bc0d 100644 --- a/README.md +++ b/README.md @@ -297,7 +297,7 @@ mkdir diagrams # start webpack dev server npm start -# accessible via localhost:8888 (webpack dev server with proxy to application server) +# accessible via localhost:8080 (webpack dev server with proxy to application server) # accesible via localhost:8080 (application server with static files) ``` diff --git a/packages/webapp/webpack/webpack.common.js b/packages/webapp/webpack/webpack.common.js index 875fdfc2..14c8b68c 100644 --- a/packages/webapp/webpack/webpack.common.js +++ b/packages/webapp/webpack/webpack.common.js @@ -77,7 +77,7 @@ module.exports = { }), new webpack.DefinePlugin({ 'process.env.APPLICATION_SERVER_VERSION': JSON.stringify(process.env.APPLICATION_SERVER_VERSION || true), - 'process.env.DEPLOYMENT_URL': JSON.stringify(process.env.DEPLOYMENT_URL || 'http://localhost:8888'), + 'process.env.DEPLOYMENT_URL': JSON.stringify(process.env.DEPLOYMENT_URL || 'http://localhost:8080'), 'process.env.SENTRY_DSN': JSON.stringify(process.env.SENTRY_DSN || null), 'process.env.POSTHOG_HOST': JSON.stringify(process.env.POSTHOG_HOST || null), 'process.env.POSTHOG_KEY': JSON.stringify(process.env.POSTHOG_KEY || null), diff --git a/packages/webapp/webpack/webpack.dev.js b/packages/webapp/webpack/webpack.dev.js index e72e66cb..ea22ad23 100644 --- a/packages/webapp/webpack/webpack.dev.js +++ b/packages/webapp/webpack/webpack.dev.js @@ -17,7 +17,7 @@ module.exports = merge(common, { devServer: { static: path.join(__dirname, '../../build/webapp'), host: '0.0.0.0', - port: 8888, + port: 8080, proxy: [ { context: ['/'], From 027fd16757521c6085788402774d3f65ad48dff8 Mon Sep 17 00:00:00 2001 From: Faris Demirovic Date: Sat, 30 Nov 2024 20:40:30 +0100 Subject: [PATCH 05/24] Format README, remove trailing backslash from example DEPLOYMENT_URL --- README.md | 63 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index a575bc0d..80e2d930 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ Apollon Standalone is the Standalone version of the [Apollon Editor](https://github.com/ls1intum/Apollon) There are two variants how you can use this editor: + 1. As web application which only runs in the users environment (modeling functionality). 2. With an application server which enables some extra features, like sharing of diagrams. @@ -20,42 +21,42 @@ All you have to do is go to the [URL](https://apollon.ase.in.tum.de/) and start The user interface of Apollon is simple to use. It works just like any other office and drawing tool that most users are familiar with. -- Select the diagram type you want to draw by clicking on the `File > New` menu. This selection determines the availability of elements that the user can use while drawing their diagram, making it easier for users who are newly introduced to modeling. -- Adding the element is as easy as dragging it from the elements menu and dropping it to the canvas. So is drawing the connection between them, simply drag and connect two or multiple elements. -- The layout of the connection is drawn automatically by the editor. If you want to manually layout it, use the existing waypoints features. -- Edit or style the text or change the colors of any elements by double-clicking on them. An easy-to-use menu will allow you to do so. -- Use keyboard shortcuts to copy, paste, delete and move the elements throughout the canvas. -- Change the theme of the editor by clicking on the dark/light mode switch. +- Select the diagram type you want to draw by clicking on the `File > New` menu. This selection determines the availability of elements that the user can use while drawing their diagram, making it easier for users who are newly introduced to modeling. +- Adding the element is as easy as dragging it from the elements menu and dropping it to the canvas. So is drawing the connection between them, simply drag and connect two or multiple elements. +- The layout of the connection is drawn automatically by the editor. If you want to manually layout it, use the existing waypoints features. +- Edit or style the text or change the colors of any elements by double-clicking on them. An easy-to-use menu will allow you to do so. +- Use keyboard shortcuts to copy, paste, delete and move the elements throughout the canvas. +- Change the theme of the editor by clicking on the dark/light mode switch. ### Import and Export your diagrams Users can easily import the existing Apollon diagram to any editor that uses the Apollon library and continue editing. -![Import Diagram](/docs/images/Import.gif "Import Diagram") +![Import Diagram](/docs/images/Import.gif 'Import Diagram') -Exporting the diagrams is as easy as importing them. +Exporting the diagrams is as easy as importing them. Click on `File > Export` and select the format of the diagram to be exported as. Currently, Apollon standalone supports five different formats: `SVG`, `PNG (White Background)`, `PNG (Transparent Background)`, `JSON`, and `PDF`. -![Export Diagram](/docs/images/Export.png "Export Diagram") +![Export Diagram](/docs/images/Export.png 'Export Diagram') ### Create diagram from template -Users in Apollon Standalone can also create a diagram from a template if they do not want to draw a diagram from scratch. +Users in Apollon Standalone can also create a diagram from a template if they do not want to draw a diagram from scratch. To do that, all they have to do is click on `File > Start from Template` and select one of the templates from the list of available templates. -![Start from Template](/docs/images/StartFromTemplate.gif "Start from Template") +![Start from Template](/docs/images/StartFromTemplate.gif 'Start from Template') ### Share your diagram with others Users can share the diagram in Apollon Standalone in four different types. -- `Edit`: In this mode of sharing, the user will be able to make changes to the shared diagram. -- `Give Feedback`: In this mode of sharing, the user will not be able to make changes to the shared diagram, but can only provide feedback to it. -- `See Feedback`: In this mode of sharing, the user can view feedback provided to the shared diagram. -- `Collaborate`: In this mode of sharing, users joining the collaboration session will be able to work on the diagram collaboratively with other users. +- `Edit`: In this mode of sharing, the user will be able to make changes to the shared diagram. +- `Give Feedback`: In this mode of sharing, the user will not be able to make changes to the shared diagram, but can only provide feedback to it. +- `See Feedback`: In this mode of sharing, the user can view feedback provided to the shared diagram. +- `Collaborate`: In this mode of sharing, users joining the collaboration session will be able to work on the diagram collaboratively with other users. -![Real-time collaboration](/docs/images/ShareDialog.png "Real-time collaboration") +![Real-time collaboration](/docs/images/ShareDialog.png 'Real-time collaboration') ### Collaborate in real-time @@ -63,7 +64,7 @@ Apollon Standalone can be used as a collaborative modeling canvas, where multipl Any changes made by one user will be visible throughout the canvas of all other users that are in collaboration sessions in real-time. Active elements that are interacted with by users in a session are highlighted in the canvas. -![Real-time collaboration](/docs/images/RealTimeCollaboration.gif "Real-time collaboration") +![Real-time collaboration](/docs/images/RealTimeCollaboration.gif 'Real-time collaboration') ## Build the application @@ -94,16 +95,17 @@ page application will be loaded. ### Web application + application server There are two variants to set this up: + 1. Manual on a linux vm 2. In a docker container - #### Manual setup (Installation of application server on linux machine) > [!IMPORTANT] > Please make sure if there is any requirements regarding additional dependencies to build the node canvas package for -your operating system! You can find instructions for installing these dependencies here: +> your operating system! You can find instructions for installing these dependencies here: > https://github.com/Automattic/node-canvas#compiling + ``` # clone the repository git clone https://github.com/ls1intum/Apollon_standalone @@ -141,16 +143,17 @@ chown apollon_standalone path/to/diagrams ``` Add the path to the created directory to: + - the cronjob in delete-stale-diagrams.cronjob.txt - in packages/server/src/main/constants.ts #### Install as a service -Configure the apollon_standalone.service file so that the paths +Configure the apollon_standalone.service file so that the paths match the paths to your installation folder ``` -# After adjusting the service file, copy the service file apollon_standalone.service +# After adjusting the service file, copy the service file apollon_standalone.service # into the /etc/systemd/system directory service apollon_standalone start cp apollon_standalone.service /etc/systemd/system/ @@ -158,7 +161,7 @@ cp apollon_standalone.service /etc/systemd/system/ cd path/to/application/build/server chmod +x server.js -# Start the service +# Start the service sudo service apollon_standalone start # Status of the service @@ -166,6 +169,7 @@ service apollon_standalone status ``` Error codes on server start: + - (code=exited, status=217/USER) -> apollon_standalone user does not exist - (code=exited, status=203/USER) -> script not executable @@ -201,7 +205,7 @@ git clone https://github.com/ls1intum/Apollon_standalone # build docker container docker build -t apollon_standalone . -run docker container +run docker container docker run -d --name apollon_standalone -p 8080:8080 apollon_standalone # build the web application and the application server @@ -225,7 +229,6 @@ To use Redis, set the environment variable `APOLLON_REDIS_URL` to the URL of the > [!IMPORTANT] > Apollon Standalone requires the Redis JSON module to be enabled. [Read the documents](https://redis.io/docs/latest/develop/data-types/json/) to learn how to enable the JSON module. - ```bash APOLLON_REDIS_URL=redis://[[username]:[password]@][host][:port] ``` @@ -267,7 +270,7 @@ Add a `.env` file in the root folder of the code. Add the following variables: ```toml # The URL of the server, e.g. the address at which # Apollon Standalone would be accessible after deployment. -DEPLOYMENT_URL=https://my.server/apollon/ +DEPLOYMENT_URL=https://my.server/apollon # The duration for which shared diagrams will be stored # (they will be removed afterwards) @@ -313,15 +316,15 @@ npm run update While developing the Standalone project, it is often required to make changes in the Apollon project. This can be achieved by executing the following workflow. -1. In the *Apollon* project: Generate a symlink by executing `npm link` command. -2. In the *Standalone* project: Link the generated symlink of Apollon *(from step 1)* by executing `npm link "@ls1intum/apollon"` command. +1. In the _Apollon_ project: Generate a symlink by executing `npm link` command. +2. In the _Standalone_ project: Link the generated symlink of Apollon _(from step 1)_ by executing `npm link "@ls1intum/apollon"` command. For more information please refer to the [documentation](https://docs.npmjs.com/cli/v9/commands/npm-link) of npm. -> ***Note***: While making changes in the *Apollon* project, for the changes to get reflected in *Standalone*, execute the following workflow: +> **_Note_**: While making changes in the _Apollon_ project, for the changes to get reflected in _Standalone_, execute the following workflow: > -> - Recompile the Apollon project by executing `npm run prepare` -> - Rebuild the Standalone project by executing `npm run build` +> - Recompile the Apollon project by executing `npm run prepare` +> - Rebuild the Standalone project by executing `npm run build` ### Using Redis in Development From d90fa08858a24751f40b2e0d6a2807f819672910 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Mon, 2 Dec 2024 14:54:05 +0100 Subject: [PATCH 06/24] modify workflow --- .github/workflows/build-and-push-docker.yml | 75 --------------------- .github/workflows/build-and-push.yml | 12 ++++ 2 files changed, 12 insertions(+), 75 deletions(-) delete mode 100644 .github/workflows/build-and-push-docker.yml create mode 100644 .github/workflows/build-and-push.yml diff --git a/.github/workflows/build-and-push-docker.yml b/.github/workflows/build-and-push-docker.yml deleted file mode 100644 index 67325cb7..00000000 --- a/.github/workflows/build-and-push-docker.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Build Docker Image - -on: - workflow_call: - outputs: - apollon_standalone_image_tag: - description: "The tag of the apollon standalone image that was built" - value: ${{ jobs.build.outputs.apollon_standalone_image_tag }} - -jobs: - build: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - dockerfile: ./Dockerfile.redis - image: ghcr.io/ls1intum/Apollon_standalone/apollon-standalone - context: . - path: apollon-standalone - outputs: - apollon_standalone_image_tag: "${{ steps.output-tag-apollon-standalone.outputs.apollon_standalone_image_tag }}" - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v44 - - - name: Log in to the Container registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: all - - - name: Install Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3 - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ matrix.image }} - tags: | - type=raw,value=latest,enable={{is_default_branch}} - type=ref,event=branch - type=ref,event=pr - - - name: Build and push Docker Image - uses: docker/build-push-action@v5 - with: - context: ${{ matrix.context }} - file: ${{ matrix.dockerfile }} - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - - - id: output-tag-apollon-standalone - run: | - if [[ "${{ matrix.path }}" == "apollon-standalone" ]] && [[ "${{ steps.changed-files.outputs.any_changed }}" == "true" ]]; then - echo "apollon_standalone_image_tag=${{ steps.meta.outputs.version }}" >> "$GITHUB_OUTPUT" - elif [[ "${{ matrix.path }}" == "server" ]]; then - echo "apollon_standalone_image_tag=latest" >> "$GITHUB_OUTPUT" - fi \ No newline at end of file diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml new file mode 100644 index 00000000..71eb101a --- /dev/null +++ b/.github/workflows/build-and-push.yml @@ -0,0 +1,12 @@ +name: Build Docker Image + +on: + push: + +jobs: + build-and-push-workflow: + uses: ls1intum/.github/.github/workflows/build-and-push-docker-image.yml@main + with: + image-name: apollon-standalone + docker-file: Dockerfile.redis + secrets: inherit \ No newline at end of file From 81b9ee269285cc79f2395342de4a42c2230675c3 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Mon, 2 Dec 2024 19:58:28 +0100 Subject: [PATCH 07/24] fix image name --- .github/workflows/build-and-push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 71eb101a..32fe5983 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -7,6 +7,6 @@ jobs: build-and-push-workflow: uses: ls1intum/.github/.github/workflows/build-and-push-docker-image.yml@main with: - image-name: apollon-standalone + image-name: Apollon_standalone/apollon-standalone docker-file: Dockerfile.redis secrets: inherit \ No newline at end of file From 63b5930726898e73ef3c2cdf92317fe61ee36d8d Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Mon, 2 Dec 2024 20:32:34 +0100 Subject: [PATCH 08/24] yolo --- .github/workflows/build-and-push-tmp.yml | 92 ++++++++++++++++++++++++ .github/workflows/build-and-push.yml | 12 +++- .github/workflows/deploy-docker.yml | 9 ++- .github/workflows/dev.yml | 5 +- docker-compose.prod.yml | 2 +- 5 files changed, 112 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/build-and-push-tmp.yml diff --git a/.github/workflows/build-and-push-tmp.yml b/.github/workflows/build-and-push-tmp.yml new file mode 100644 index 00000000..55d32ea9 --- /dev/null +++ b/.github/workflows/build-and-push-tmp.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 32fe5983..2c840505 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -1,12 +1,18 @@ name: Build Docker Image on: - push: + 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: - uses: ls1intum/.github/.github/workflows/build-and-push-docker-image.yml@main + 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: Apollon_standalone/apollon-standalone + image-name: ls1intum/Apollon_standalone docker-file: Dockerfile.redis secrets: inherit \ No newline at end of file diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/deploy-docker.yml index d3a917c5..bfab1d37 100644 --- a/.github/workflows/deploy-docker.yml +++ b/.github/workflows/deploy-docker.yml @@ -6,9 +6,14 @@ on: environment: required: true type: string - apollon_standalone_image_tag: + 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: @@ -64,7 +69,7 @@ jobs: echo "DEPLOYMENT_URL=${{ vars.DEPLOYMENT_URL }}" > .env.prod echo "APOLLON_REDIS_DIAGRAM_TTL=${{ vars.APOLLON_REDIS_DIAGRAM_TTL }}" >> .env.prod - echo "APOLLON_STANDALONE_IMAGE_TAG=${{ inputs.apollon_standalone_image_tag }}" >> .env.prod + echo "IMAGE_TAG=${{ inputs.image-tag }}" >> .env.prod - name: SSH to VM and Execute Docker-Compose Up uses: appleboy/ssh-action@v1.0.3 diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index b51025e4..f1ed40e6 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -5,7 +5,7 @@ on: jobs: build-dev-container: - uses: ./.github/workflows/build-and-push-docker.yml + uses: ./.github/workflows/build-and-push.yml secrets: inherit deploy-dev-container: needs: build-dev-container @@ -13,4 +13,5 @@ jobs: secrets: inherit with: environment: Dev - apollon_standalone_image_tag: "${{ needs.build-dev-container.outputs.apollon_standalone_image_tag }}" \ No newline at end of file + image-name: ls1intum/Apollon_standalone + image-tag: "${{ needs.build-dev-container.outputs.image-tag }}" \ No newline at end of file diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 060e2e3a..f35a8bfa 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -16,7 +16,7 @@ services: - apollon-network apollon_standalone: - image: "ghcr.io/ls1intum/Apollon_standalone/apollon-standalone:${APOLLON_STANDALONE_IMAGE_TAG}" + image: "ghcr.io/ls1intum/Apollon_standalone/apollon-standalone:${IMAGE_TAG}" container_name: apollon-standalone environment: - APOLLON_REDIS_URL=redis://apollon_redis:6379 From f28b3ad78a52d871a35cfdc2f5c91698422e5276 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Mon, 2 Dec 2024 21:07:38 +0100 Subject: [PATCH 09/24] fix error --- .github/workflows/deploy-docker.yml | 2 +- .github/workflows/dev.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/deploy-docker.yml index bfab1d37..bd3b57eb 100644 --- a/.github/workflows/deploy-docker.yml +++ b/.github/workflows/deploy-docker.yml @@ -33,7 +33,7 @@ jobs: 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 down --remove-orphans --rmi all + docker compose -f docker-compose.prod.yml down --remove-orphans --rmi all - name: checkout uses: actions/checkout@v4 diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index f1ed40e6..1e003096 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -2,6 +2,7 @@ name: Build and Deploy to Dev on: pull_request: + branches: [main] jobs: build-dev-container: From b7be687592e87e770f2b2cb53049af8d957ea3ce Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Mon, 2 Dec 2024 21:27:44 +0100 Subject: [PATCH 10/24] remove needed file --- .github/workflows/deploy-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/deploy-docker.yml index bd3b57eb..dd498555 100644 --- a/.github/workflows/deploy-docker.yml +++ b/.github/workflows/deploy-docker.yml @@ -33,7 +33,7 @@ jobs: proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }} proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }} script: | - docker compose -f docker-compose.prod.yml down --remove-orphans --rmi all + docker compose down --remove-orphans --rmi all - name: checkout uses: actions/checkout@v4 From 4aa9d1e5ef54e091b446d78298f65113ee9c2f80 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Mon, 2 Dec 2024 21:48:41 +0100 Subject: [PATCH 11/24] update --- .github/workflows/build-and-push-tmp.yml | 4 +++- .github/workflows/deploy-docker.yml | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-push-tmp.yml b/.github/workflows/build-and-push-tmp.yml index 55d32ea9..830d794b 100644 --- a/.github/workflows/build-and-push-tmp.yml +++ b/.github/workflows/build-and-push-tmp.yml @@ -89,4 +89,6 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-args: ${{ inputs.build-args }} - push: true \ No newline at end of file + push: true + cache-from: type=gha,scope=${{ inputs.image-name }} + cache-to: type=gha,scope=${{ inputs.image-name }},mode=max diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/deploy-docker.yml index dd498555..ec9ca1ab 100644 --- a/.github/workflows/deploy-docker.yml +++ b/.github/workflows/deploy-docker.yml @@ -22,7 +22,7 @@ jobs: name: ${{ inputs.environment }} url: 'https://${{ vars.SERVER_HOST }}' steps: - - name: SSH to VM and Execute Docker-Compose Down + - name: SSH to VM and Execute Docker-Compose Down (if exists) uses: appleboy/ssh-action@v1.0.3 with: host: ${{ vars.VM_HOST }} @@ -33,7 +33,25 @@ jobs: proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }} proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }} script: | - docker compose down --remove-orphans --rmi all + #!/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 From a6887d76c8a146fe89afd575159642068b78fe59 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Mon, 2 Dec 2024 22:07:40 +0100 Subject: [PATCH 12/24] fix compose file --- docker-compose.prod.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index f35a8bfa..62b84238 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -15,8 +15,8 @@ services: networks: - apollon-network - apollon_standalone: - image: "ghcr.io/ls1intum/Apollon_standalone/apollon-standalone:${IMAGE_TAG}" + apollon-standalone: + image: "ghcr.io/ls1intum/apollon_standalone:${IMAGE_TAG}" container_name: apollon-standalone environment: - APOLLON_REDIS_URL=redis://apollon_redis:6379 From f6757fd9b8e6d14a602a5a4ff2b82841890983b0 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Mon, 2 Dec 2024 22:31:00 +0100 Subject: [PATCH 13/24] fix casing --- .github/workflows/build-and-push.yml | 2 +- .github/workflows/dev.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 2c840505..f454f3f6 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -13,6 +13,6 @@ jobs: # 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 + image-name: ls1intum/apollon_standalone docker-file: Dockerfile.redis secrets: inherit \ No newline at end of file diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 1e003096..734ac014 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -14,5 +14,5 @@ jobs: secrets: inherit with: environment: Dev - image-name: ls1intum/Apollon_standalone + image-name: ls1intum/apollon_standalone image-tag: "${{ needs.build-dev-container.outputs.image-tag }}" \ No newline at end of file From 1f70b29bcdca405508e3814429f96444ac1ed8b6 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Mon, 2 Dec 2024 22:48:45 +0100 Subject: [PATCH 14/24] remove cache --- .github/workflows/build-and-push-tmp.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build-and-push-tmp.yml b/.github/workflows/build-and-push-tmp.yml index 830d794b..55d32ea9 100644 --- a/.github/workflows/build-and-push-tmp.yml +++ b/.github/workflows/build-and-push-tmp.yml @@ -89,6 +89,4 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-args: ${{ inputs.build-args }} - push: true - cache-from: type=gha,scope=${{ inputs.image-name }} - cache-to: type=gha,scope=${{ inputs.image-name }},mode=max + push: true \ No newline at end of file From a7ef550b1d0899bec675fd20c6f52d98363bd173 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Mon, 2 Dec 2024 23:18:50 +0100 Subject: [PATCH 15/24] map to host --- docker-compose.prod.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 62b84238..b9cd0452 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -23,8 +23,8 @@ services: - APOLLON_REDIS_DIAGRAM_TTL=${APOLLON_REDIS_DIAGRAM_TTL} - DEPLOYMENT_URL=${DEPLOYMENT_URL} restart: unless-stopped - expose: - - "8080" + ports: + - "8080:8080" depends_on: redis: condition: service_healthy From a633da3fade2c38f2676e23cf4c916b90efeb9b0 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Mon, 2 Dec 2024 23:51:49 +0100 Subject: [PATCH 16/24] fix redis --- docker-compose.prod.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index b9cd0452..54ac0cba 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -19,7 +19,7 @@ services: image: "ghcr.io/ls1intum/apollon_standalone:${IMAGE_TAG}" container_name: apollon-standalone environment: - - APOLLON_REDIS_URL=redis://apollon_redis:6379 + - APOLLON_REDIS_URL=redis://apollon-redis:6379 - APOLLON_REDIS_DIAGRAM_TTL=${APOLLON_REDIS_DIAGRAM_TTL} - DEPLOYMENT_URL=${DEPLOYMENT_URL} restart: unless-stopped From 6d914c4090212e939d5e3151f3acee835774b1d9 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Tue, 3 Dec 2024 01:00:46 +0100 Subject: [PATCH 17/24] remove arg --- Dockerfile.redis | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Dockerfile.redis b/Dockerfile.redis index e3b0bd49..bad7eb50 100644 --- a/Dockerfile.redis +++ b/Dockerfile.redis @@ -7,14 +7,9 @@ RUN apk add --no-cache \ pango-dev \ giflib-dev - -ARG DEPLOYMENT_URL="http://localhost:8080" -ARG APOLLON_REDIS_URL="redis://localhost:6379" -ARG APOLLON_REDIS_DIAGRAM_TTL="30d" - -ENV DEPLOYMENT_URL=${DEPLOYMENT_URL} -ENV APOLLON_REDIS_URL=${APOLLON_REDIS_URL} -ENV APOLLON_REDIS_DIAGRAM_TTL=${APOLLON_REDIS_DIAGRAM_TTL} +ENV DEPLOYMENT_URL="http://localhost:8080" +ENV APOLLON_REDIS_URL="redis://localhost:6379" +ENV APOLLON_REDIS_DIAGRAM_TTL="30d" WORKDIR /app From afac92f54e448c1645fa0e4f80e7bd047c9ecffc Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Tue, 3 Dec 2024 01:13:03 +0100 Subject: [PATCH 18/24] fix deployment url --- Dockerfile.redis | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile.redis b/Dockerfile.redis index bad7eb50..4685edcd 100644 --- a/Dockerfile.redis +++ b/Dockerfile.redis @@ -21,4 +21,5 @@ WORKDIR /app/build/server EXPOSE 8080 +ENTRYPOINT [ "sed", "-i", "s|http://localhost:8080|${DEPLOYMENT_URL}|g", "/app/build/webapp/*.js" ] CMD [ "node", "bundle.js" ] From f1da6b56b17c780e7ad55e5c26c12fe364383cff Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Tue, 3 Dec 2024 01:39:00 +0100 Subject: [PATCH 19/24] fix sed --- Dockerfile.redis | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.redis b/Dockerfile.redis index 4685edcd..02c1d5d3 100644 --- a/Dockerfile.redis +++ b/Dockerfile.redis @@ -21,5 +21,5 @@ WORKDIR /app/build/server EXPOSE 8080 -ENTRYPOINT [ "sed", "-i", "s|http://localhost:8080|${DEPLOYMENT_URL}|g", "/app/build/webapp/*.js" ] +ENTRYPOINT [ "sed", "-i", "s|http://localhost:8080|${DEPLOYMENT_URL}|g", "../webapp/*.js" ] CMD [ "node", "bundle.js" ] From e82c13ca5904b98b48fba40db7242fe9149f7117 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Tue, 3 Dec 2024 02:18:17 +0100 Subject: [PATCH 20/24] fix url --- Dockerfile.redis | 1 - packages/server/src/main/server.ts | 11 +++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Dockerfile.redis b/Dockerfile.redis index 02c1d5d3..bad7eb50 100644 --- a/Dockerfile.redis +++ b/Dockerfile.redis @@ -21,5 +21,4 @@ WORKDIR /app/build/server EXPOSE 8080 -ENTRYPOINT [ "sed", "-i", "s|http://localhost:8080|${DEPLOYMENT_URL}|g", "../webapp/*.js" ] CMD [ "node", "bundle.js" ] diff --git a/packages/server/src/main/server.ts b/packages/server/src/main/server.ts index 21143e1c..281f32d2 100644 --- a/packages/server/src/main/server.ts +++ b/packages/server/src/main/server.ts @@ -1,3 +1,5 @@ +import fs from 'fs'; +import path from 'path'; import bodyParser from 'body-parser'; import express, { RequestHandler } from 'express'; import * as Sentry from '@sentry/node'; @@ -19,6 +21,15 @@ if (process.env.SENTRY_DSN) { Sentry.setTag('package', 'server'); } +// Replace http://localhost:8080 with the actual process.env.DEPLOYMENT_URL +const jsFiles = fs.readdirSync(webappPath).filter((file) => file.endsWith('.js')); +jsFiles.forEach((file) => { + const filePath = path.join(webappPath, file); + const content = fs.readFileSync(filePath, 'utf8') + .replace(/http:\/\/localhost:8080/g, process.env.DEPLOYMENT_URL || 'http://localhost:8080'); + fs.writeFileSync(filePath, content); +}); + app.use('/', express.static(webappPath)); app.use(bodyParser.json() as RequestHandler); app.use( From 8441c0431197dceb726f00d6bebf25c48b43f213 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Thu, 5 Dec 2024 13:48:11 +0100 Subject: [PATCH 21/24] rename file --- .../{build-and-push-tmp.yml => build-and-push-shared.yml} | 0 .github/workflows/build-and-push.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{build-and-push-tmp.yml => build-and-push-shared.yml} (100%) diff --git a/.github/workflows/build-and-push-tmp.yml b/.github/workflows/build-and-push-shared.yml similarity index 100% rename from .github/workflows/build-and-push-tmp.yml rename to .github/workflows/build-and-push-shared.yml diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index f454f3f6..986fde7c 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -11,7 +11,7 @@ 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 + uses: ./.github/workflows/build-and-push-shared.yml with: image-name: ls1intum/apollon_standalone docker-file: Dockerfile.redis From cb55cc8deff0dd8ec2ada7d9aadd36f2d06c6cb0 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Thu, 5 Dec 2024 15:10:51 +0100 Subject: [PATCH 22/24] generalize docker compose deploy --- .github/workflows/build-and-push-shared.yml | 2 + .github/workflows/build-and-push.yml | 2 +- .../deploy-docker-compose-shared.yml | 106 ++++++++++++++++++ .github/workflows/deploy-docker.yml | 102 ++--------------- .github/workflows/dev.yml | 1 - 5 files changed, 121 insertions(+), 92 deletions(-) create mode 100644 .github/workflows/deploy-docker-compose-shared.yml diff --git a/.github/workflows/build-and-push-shared.yml b/.github/workflows/build-and-push-shared.yml index 55d32ea9..7a7047ec 100644 --- a/.github/workflows/build-and-push-shared.yml +++ b/.github/workflows/build-and-push-shared.yml @@ -75,6 +75,8 @@ jobs: type=raw,value=latest,enable={{is_default_branch}} type=ref,event=branch type=ref,event=pr + type=semver,pattern={{version}} + type=sha,prefix=,format=long - name: Set image tag output id: set-tag diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 986fde7c..94cdabff 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -10,7 +10,7 @@ on: jobs: build-and-push-workflow: name: Build and Push Docker Image - # uses: ls1intum/.github/.github/workflows/build-and-push-docker-image.yml@main + # TODO: uses: ls1intum/.github/.github/workflows/build-and-push-docker-image.yml@main uses: ./.github/workflows/build-and-push-shared.yml with: image-name: ls1intum/apollon_standalone diff --git a/.github/workflows/deploy-docker-compose-shared.yml b/.github/workflows/deploy-docker-compose-shared.yml new file mode 100644 index 00000000..a5e2827c --- /dev/null +++ b/.github/workflows/deploy-docker-compose-shared.yml @@ -0,0 +1,106 @@ +# ls1intum/.github/workflows/deploy-docker-compose.yml +name: Deploy Docker Compose + +on: + workflow_call: + inputs: + environment: + type: string + description: "The deployment environment (e.g., production, staging)" + required: true + docker-compose-file: + type: string + default: "./docker-compose.yml" + description: "Path to the Docker Compose file (Default: ./docker-compose.yml)" + image-tag: + type: string + default: latest + description: "Tag of the Docker images to deploy (Default: latest)" + env-vars: + type: string + description: "Additional environment variables in KEY=VALUE format, separated by newlines" + required: false + +jobs: + deploy: + runs-on: ubuntu-latest + environment: + name: ${{ inputs.environment }} + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: SSH to VM and Execute Docker-Compose Down (if exists) + uses: appleboy/ssh-action@v1.0.3 + 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="${{ inputs.docker-compose-file }}" + + # Check if docker-compose.prod.yml exists + if [ -f "$COMPOSE_FILE" ]; then + echo "$COMPOSE_FILE found." + + # Check if .env exists + if [ -f ".env" ]; then + docker compose -f "$COMPOSE_FILE" --env-file=".env" 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: Copy Docker Compose File to VM Host + uses: appleboy/scp-action@v0.1.7 + 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: ${{ inputs.docker-compose-file }} + target: /home/${{ vars.VM_USERNAME }} + + - name: SSH to VM and Create .env File + uses: appleboy/ssh-action@v1.0.3 + 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 + + echo "ENVIRONMENT=${{ inputs.environment }}" > .env + echo "IMAGE_TAG=${{ inputs.image-tag }}" >> .env + if [ "${{ inputs.env-vars }}" != "" ]; then + echo "${{ inputs.env-vars }}" >> .env + fi + + - name: SSH to VM and Execute Docker Compose Up + uses: appleboy/ssh-action@v1.0.3 + 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 ${{ inputs.docker-compose-file }} --env-file=.env up --pull=always -d \ No newline at end of file diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/deploy-docker.yml index ec9ca1ab..f04e3cac 100644 --- a/.github/workflows/deploy-docker.yml +++ b/.github/workflows/deploy-docker.yml @@ -1,4 +1,4 @@ -name: Deploy Docker Image +name: Deploy Docker Compose on: workflow_call: @@ -6,98 +6,20 @@ on: 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)" + description: "The tag for the docker images (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/ssh-action@v1.0.3 - 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/scp-action@v0.1.7 - 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/ssh-action@v1.0.3 - 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/ssh-action@v1.0.3 - 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 \ No newline at end of file + # TODO: uses: ls1intum/.github/.github/workflows/deploy-docker-compose.yml@main + uses: ./.github/workflows/deploy-docker-compose-shared.yml + with: + environment: ${{ inputs.environment }} + docker-compose-file: "./docker-compose.prod.yml" + image-tag: ${{ inputs.image-tag }} + env-vars: | + DEPLOYMENT_URL=${{ vars.DEPLOYMENT_URL }} + APOLLON_REDIS_DIAGRAM_TTL=${{ vars.APOLLON_REDIS_DIAGRAM_TTL }} + secrets: inherit diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 734ac014..2fadb821 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -14,5 +14,4 @@ jobs: secrets: inherit with: environment: Dev - image-name: ls1intum/apollon_standalone image-tag: "${{ needs.build-dev-container.outputs.image-tag }}" \ No newline at end of file From 163590685cce1f631ea5afe9f4e0574b52f9946e Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Fri, 6 Dec 2024 15:46:16 +0100 Subject: [PATCH 23/24] use workflow_dispatch --- .github/workflows/build-and-push.yml | 8 +++----- .../{deploy-docker.yml => deploy-dev.yml} | 14 +++++--------- .github/workflows/dev.yml | 17 ----------------- 3 files changed, 8 insertions(+), 31 deletions(-) rename .github/workflows/{deploy-docker.yml => deploy-dev.yml} (69%) delete mode 100644 .github/workflows/dev.yml diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 94cdabff..093fa920 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -1,11 +1,9 @@ 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 }} + pull_request: + push: + branches: [main] jobs: build-and-push-workflow: diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/deploy-dev.yml similarity index 69% rename from .github/workflows/deploy-docker.yml rename to .github/workflows/deploy-dev.yml index f04e3cac..59c1b95a 100644 --- a/.github/workflows/deploy-docker.yml +++ b/.github/workflows/deploy-dev.yml @@ -1,22 +1,18 @@ -name: Deploy Docker Compose +name: Deploy Dev on: - workflow_call: + workflow_dispatch: inputs: - environment: - required: true - type: string image-tag: - default: "latest" type: string - description: "The tag for the docker images (Default: latest)" - + description: "The tag of the docker images to deploy" + required: true jobs: deploy: # TODO: uses: ls1intum/.github/.github/workflows/deploy-docker-compose.yml@main uses: ./.github/workflows/deploy-docker-compose-shared.yml with: - environment: ${{ inputs.environment }} + environment: Dev docker-compose-file: "./docker-compose.prod.yml" image-tag: ${{ inputs.image-tag }} env-vars: | diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml deleted file mode 100644 index 2fadb821..00000000 --- a/.github/workflows/dev.yml +++ /dev/null @@ -1,17 +0,0 @@ -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-tag: "${{ needs.build-dev-container.outputs.image-tag }}" \ No newline at end of file From d848da6ec02e4779cdd9dbabebb334446d849ef9 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Fri, 6 Dec 2024 15:48:16 +0100 Subject: [PATCH 24/24] revert readme --- README.md | 65 ++++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 80e2d930..77ff7509 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ Apollon Standalone is the Standalone version of the [Apollon Editor](https://github.com/ls1intum/Apollon) There are two variants how you can use this editor: - 1. As web application which only runs in the users environment (modeling functionality). 2. With an application server which enables some extra features, like sharing of diagrams. @@ -21,42 +20,42 @@ All you have to do is go to the [URL](https://apollon.ase.in.tum.de/) and start The user interface of Apollon is simple to use. It works just like any other office and drawing tool that most users are familiar with. -- Select the diagram type you want to draw by clicking on the `File > New` menu. This selection determines the availability of elements that the user can use while drawing their diagram, making it easier for users who are newly introduced to modeling. -- Adding the element is as easy as dragging it from the elements menu and dropping it to the canvas. So is drawing the connection between them, simply drag and connect two or multiple elements. -- The layout of the connection is drawn automatically by the editor. If you want to manually layout it, use the existing waypoints features. -- Edit or style the text or change the colors of any elements by double-clicking on them. An easy-to-use menu will allow you to do so. -- Use keyboard shortcuts to copy, paste, delete and move the elements throughout the canvas. -- Change the theme of the editor by clicking on the dark/light mode switch. +- Select the diagram type you want to draw by clicking on the `File > New` menu. This selection determines the availability of elements that the user can use while drawing their diagram, making it easier for users who are newly introduced to modeling. +- Adding the element is as easy as dragging it from the elements menu and dropping it to the canvas. So is drawing the connection between them, simply drag and connect two or multiple elements. +- The layout of the connection is drawn automatically by the editor. If you want to manually layout it, use the existing waypoints features. +- Edit or style the text or change the colors of any elements by double-clicking on them. An easy-to-use menu will allow you to do so. +- Use keyboard shortcuts to copy, paste, delete and move the elements throughout the canvas. +- Change the theme of the editor by clicking on the dark/light mode switch. ### Import and Export your diagrams Users can easily import the existing Apollon diagram to any editor that uses the Apollon library and continue editing. -![Import Diagram](/docs/images/Import.gif 'Import Diagram') +![Import Diagram](/docs/images/Import.gif "Import Diagram") -Exporting the diagrams is as easy as importing them. +Exporting the diagrams is as easy as importing them. Click on `File > Export` and select the format of the diagram to be exported as. Currently, Apollon standalone supports five different formats: `SVG`, `PNG (White Background)`, `PNG (Transparent Background)`, `JSON`, and `PDF`. -![Export Diagram](/docs/images/Export.png 'Export Diagram') +![Export Diagram](/docs/images/Export.png "Export Diagram") ### Create diagram from template -Users in Apollon Standalone can also create a diagram from a template if they do not want to draw a diagram from scratch. +Users in Apollon Standalone can also create a diagram from a template if they do not want to draw a diagram from scratch. To do that, all they have to do is click on `File > Start from Template` and select one of the templates from the list of available templates. -![Start from Template](/docs/images/StartFromTemplate.gif 'Start from Template') +![Start from Template](/docs/images/StartFromTemplate.gif "Start from Template") ### Share your diagram with others Users can share the diagram in Apollon Standalone in four different types. -- `Edit`: In this mode of sharing, the user will be able to make changes to the shared diagram. -- `Give Feedback`: In this mode of sharing, the user will not be able to make changes to the shared diagram, but can only provide feedback to it. -- `See Feedback`: In this mode of sharing, the user can view feedback provided to the shared diagram. -- `Collaborate`: In this mode of sharing, users joining the collaboration session will be able to work on the diagram collaboratively with other users. +- `Edit`: In this mode of sharing, the user will be able to make changes to the shared diagram. +- `Give Feedback`: In this mode of sharing, the user will not be able to make changes to the shared diagram, but can only provide feedback to it. +- `See Feedback`: In this mode of sharing, the user can view feedback provided to the shared diagram. +- `Collaborate`: In this mode of sharing, users joining the collaboration session will be able to work on the diagram collaboratively with other users. -![Real-time collaboration](/docs/images/ShareDialog.png 'Real-time collaboration') +![Real-time collaboration](/docs/images/ShareDialog.png "Real-time collaboration") ### Collaborate in real-time @@ -64,7 +63,7 @@ Apollon Standalone can be used as a collaborative modeling canvas, where multipl Any changes made by one user will be visible throughout the canvas of all other users that are in collaboration sessions in real-time. Active elements that are interacted with by users in a session are highlighted in the canvas. -![Real-time collaboration](/docs/images/RealTimeCollaboration.gif 'Real-time collaboration') +![Real-time collaboration](/docs/images/RealTimeCollaboration.gif "Real-time collaboration") ## Build the application @@ -95,17 +94,16 @@ page application will be loaded. ### Web application + application server There are two variants to set this up: - 1. Manual on a linux vm 2. In a docker container + #### Manual setup (Installation of application server on linux machine) > [!IMPORTANT] > Please make sure if there is any requirements regarding additional dependencies to build the node canvas package for -> your operating system! You can find instructions for installing these dependencies here: +your operating system! You can find instructions for installing these dependencies here: > https://github.com/Automattic/node-canvas#compiling - ``` # clone the repository git clone https://github.com/ls1intum/Apollon_standalone @@ -143,17 +141,16 @@ chown apollon_standalone path/to/diagrams ``` Add the path to the created directory to: - - the cronjob in delete-stale-diagrams.cronjob.txt - in packages/server/src/main/constants.ts #### Install as a service -Configure the apollon_standalone.service file so that the paths +Configure the apollon_standalone.service file so that the paths match the paths to your installation folder ``` -# After adjusting the service file, copy the service file apollon_standalone.service +# After adjusting the service file, copy the service file apollon_standalone.service # into the /etc/systemd/system directory service apollon_standalone start cp apollon_standalone.service /etc/systemd/system/ @@ -161,7 +158,7 @@ cp apollon_standalone.service /etc/systemd/system/ cd path/to/application/build/server chmod +x server.js -# Start the service +# Start the service sudo service apollon_standalone start # Status of the service @@ -169,7 +166,6 @@ service apollon_standalone status ``` Error codes on server start: - - (code=exited, status=217/USER) -> apollon_standalone user does not exist - (code=exited, status=203/USER) -> script not executable @@ -205,7 +201,7 @@ git clone https://github.com/ls1intum/Apollon_standalone # build docker container docker build -t apollon_standalone . -run docker container +run docker container docker run -d --name apollon_standalone -p 8080:8080 apollon_standalone # build the web application and the application server @@ -229,6 +225,7 @@ To use Redis, set the environment variable `APOLLON_REDIS_URL` to the URL of the > [!IMPORTANT] > Apollon Standalone requires the Redis JSON module to be enabled. [Read the documents](https://redis.io/docs/latest/develop/data-types/json/) to learn how to enable the JSON module. + ```bash APOLLON_REDIS_URL=redis://[[username]:[password]@][host][:port] ``` @@ -270,7 +267,7 @@ Add a `.env` file in the root folder of the code. Add the following variables: ```toml # The URL of the server, e.g. the address at which # Apollon Standalone would be accessible after deployment. -DEPLOYMENT_URL=https://my.server/apollon +DEPLOYMENT_URL=https://my.server/apollon/ # The duration for which shared diagrams will be stored # (they will be removed afterwards) @@ -300,7 +297,7 @@ mkdir diagrams # start webpack dev server npm start -# accessible via localhost:8080 (webpack dev server with proxy to application server) +# accessible via localhost:8888 (webpack dev server with proxy to application server) # accesible via localhost:8080 (application server with static files) ``` @@ -316,15 +313,15 @@ npm run update While developing the Standalone project, it is often required to make changes in the Apollon project. This can be achieved by executing the following workflow. -1. In the _Apollon_ project: Generate a symlink by executing `npm link` command. -2. In the _Standalone_ project: Link the generated symlink of Apollon _(from step 1)_ by executing `npm link "@ls1intum/apollon"` command. +1. In the *Apollon* project: Generate a symlink by executing `npm link` command. +2. In the *Standalone* project: Link the generated symlink of Apollon *(from step 1)* by executing `npm link "@ls1intum/apollon"` command. For more information please refer to the [documentation](https://docs.npmjs.com/cli/v9/commands/npm-link) of npm. -> **_Note_**: While making changes in the _Apollon_ project, for the changes to get reflected in _Standalone_, execute the following workflow: +> ***Note***: While making changes in the *Apollon* project, for the changes to get reflected in *Standalone*, execute the following workflow: > -> - Recompile the Apollon project by executing `npm run prepare` -> - Rebuild the Standalone project by executing `npm run build` +> - Recompile the Apollon project by executing `npm run prepare` +> - Rebuild the Standalone project by executing `npm run build` ### Using Redis in Development