diff --git a/.github/workflows/build-container.yml b/.github/workflows/build-container.yml new file mode 100644 index 0000000..ffbecf5 --- /dev/null +++ b/.github/workflows/build-container.yml @@ -0,0 +1,24 @@ +name: Create and publish container +on: + release: + types: [published] + workflow_dispatch: +jobs: + build_container: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Check out Git repository + uses: actions/checkout@v6 + with: + ref: ${{ github.ref }} + - name: Build image + run: docker buildx build . --tag ghcr.io/studyphoenix/frontend --build-arg GIT_REF="$( git rev-parse HEAD )" + - name: Login to registry + run: | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + - name: Publish to GitHub Container Registry + run: | + docker push ghcr.io/studyphoenix/frontend diff --git a/.github/workflows/update-types.yml b/.github/workflows/update-types.yml new file mode 100644 index 0000000..fe43728 --- /dev/null +++ b/.github/workflows/update-types.yml @@ -0,0 +1,22 @@ +name: Update data types +on: + workflow_dispatch: +env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} +jobs: + run_eslint: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Check out Git repository + uses: actions/checkout@v6 + with: + ref: ${{ env.BRANCH_NAME }} + persist-credentials: true + - name: Generate types + run: ./generate-types.yml ci + - name: Push changes back to repository + uses: stefanzweifel/git-auto-commit-action@v7 + with: + commit_message: "chore: updated data types for API [skip ci]" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..57cb183 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM node:25-alpine3.21 AS build + +ARG GIT_REF="studyphoenix" + +# Frontend Build stage +WORKDIR /usr/src/build + +ENV VITE_GIT_REF="${GIT_REF}" + +COPY . /usr/src/build + +RUN npm i +RUN npm run build + +# Build final image +FROM nginx AS prod +COPY --from=build /usr/src/build/dist /usr/share/nginx/html +COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf +EXPOSE 3000 diff --git a/compose.yml b/compose.yml index 9a5451e..3fd5541 100644 --- a/compose.yml +++ b/compose.yml @@ -13,5 +13,10 @@ services: restart: on-failure ports: - 8080:8080 + environment: + DATA_DIR: /data + BACKEND_URL: http://localhost:8080 + FRONTEND_URL: http://localhost:8081 + DEFAULT_REDIRECT: http://localhost:8081 volumes: - ./backend-data:/data diff --git a/generate-types.sh b/generate-types.sh index 474dd79..77960ef 100755 --- a/generate-types.sh +++ b/generate-types.sh @@ -1,6 +1,10 @@ #!/bin/bash -if [[ $1 != "" ]]; then +set -e + +if [[ $1 == "ci" ]]; then + npx --yes swagger-typescript-api@13.13.0 generate --path https://raw.githubusercontent.com/studyphoenix/backend/refs/heads/main/docs/swagger.json -o ./src/ts/types -n api.d.ts --no-client +elif [[ $1 != "" ]]; then npx swagger-typescript-api@13.13.0 generate --path http://$1:8080/swagger/doc.json -o ./src/ts/types -n api.d.ts --no-client else npx swagger-typescript-api@13.13.0 generate --path https://raw.githubusercontent.com/studyphoenix/backend/refs/heads/main/docs/swagger.json -o ./src/ts/types -n api.d.ts --no-client diff --git a/launch.sh b/launch.sh new file mode 100755 index 0000000..63f69cf --- /dev/null +++ b/launch.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +set -e +docker compose pull +docker compose down && docker compose up -d diff --git a/nginx/default.conf b/nginx/default.conf new file mode 100644 index 0000000..ac25660 --- /dev/null +++ b/nginx/default.conf @@ -0,0 +1,16 @@ +server { + listen 3000; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html; + } + + error_page 404 /index.html; + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} diff --git a/package.json b/package.json index f26f84a..b9440d0 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "@fontsource/roboto": "^5.2.10", - "@janishutz/oidc-login-sdk-browser": "^1.5.3", + "@janishutz/oidc-login-sdk-browser": "^1.7.0", "@mdi/font": "7.4.47", "pinia": "^3.0.4", "vue": "^3.5.30", diff --git a/run-lint.sh b/run-lint.sh index bec200c..4b62bc9 100755 --- a/run-lint.sh +++ b/run-lint.sh @@ -1,6 +1,11 @@ #!/bin/bash -docker run -v .:/mnt -e VITE_BACKENDLESS=true --name linter ghcr.io/janishutz/vue-dev-runner -docker exec linter bash -c "npm run type-check && npm run lint-fix" -docker stop linter -docker rm linter +if [[ $1 == "local" ]]; then + npm run lint-fix + npm run type-check +else + docker run -v .:/mnt -e VITE_BACKENDLESS=true --name linter ghcr.io/janishutz/vue-dev-runner + docker exec linter bash -c "npm run lint-fix && npm run type-check" + docker stop linter + docker rm linter +fi diff --git a/src/components/SideBar.vue b/src/components/SideBar.vue index c3769fd..2f7b3e7 100644 --- a/src/components/SideBar.vue +++ b/src/components/SideBar.vue @@ -1,9 +1,16 @@