From 3ffd8dca571a92bf499a15784a4b66b20a94c9f9 Mon Sep 17 00:00:00 2001 From: Jan-David Wiederstein Date: Fri, 13 Jun 2025 09:21:41 +0000 Subject: [PATCH] gitlab pr deployments --- .gitlab-ci.yml | 40 ++++++++++++++++++++++++++++++++++++++++ ci.prod.yml | 23 ++++++++++------------- 2 files changed, 50 insertions(+), 13 deletions(-) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..09138ab --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,40 @@ +workflow: + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + +stages: + - deploy + +codesphere-deploy: + image: ghcr.io/codesphere-cloud/codesphere-monorepo/integrations/gitlab-ci:latest + stage: deploy + script: + - node /app/server.js + variables: + ACCESS_TOKEN: $CI_ACCESS_TOKEN + EMAIL: $CODESPHERE_EMAIL + PASSWORD: $CODESPHERE_PASSWORD + TEAM: 'Hackathon Playground' + PLAN: 'Micro' + ON_DEMAND: 'false' + ENV: | + CS_TOKEN=$CODESPHERE_TOKEN + environment: + name: 'Preview Deployment Python MR_$CI_MERGE_REQUEST_IID' + on_stop: codesphere-teardown + +codesphere-teardown: + when: manual + image: ghcr.io/codesphere-cloud/codesphere-monorepo/integrations/gitlab-ci:latest + stage: deploy + script: + - node /app/server.js + variables: + ACCESS_TOKEN: $CI_ACCESS_TOKEN + EMAIL: $CODESPHERE_EMAIL + PASSWORD: $CODESPHERE_PASSWORD + TEAM: 'Hackathon Playground' + environment: + name: 'Preview Deployment Python MR_$CI_MERGE_REQUEST_IID' + action: stop + diff --git a/ci.prod.yml b/ci.prod.yml index 01109f7..2f51ae9 100644 --- a/ci.prod.yml +++ b/ci.prod.yml @@ -8,8 +8,7 @@ prepare: sed s/\".*$// | xargs wget -O $HOME/.local/bin/cs && chmod +x $HOME/.local/bin/cs - name: install uv standalone version - command: curl -LsSf https://astral.sh/uv/install.sh | env - UV_INSTALL_DIR="$HOME/app" sh && chmod +x $HOME/app/uv + command: nix-env -iA nixpkgs.uv - name: "set ev vars " command: . .env && cs set-env -w $WORKSPACE_ID -t $TEAM_ID --env-var UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install @@ -17,20 +16,18 @@ prepare: --env-var UV_CACHE_DIR=$PWD/.codesphere-internal/.uv --env-var UV_PYTHON_CACHE_DIR=$PWD/.codesphere-internal/.uv-python - name: install frontend environment - command: . ./env && cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync - --no-dev; } + command: cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync --no-dev; } - name: install backend environment - command: . ./env && cd backend && { [ ! -d ".venv" ] && uv venv; uv sync - --no-dev; } + command: cd backend && { [ ! -d ".venv" ] && uv venv; uv sync --no-dev; } test: steps: [] run: frontend: steps: - name: start frontend application - command: ". ./env && cd frontend && uv run streamlit run main.py - --server.headless true --server.address 0.0.0.0 --server.port 3000 - --browser.gatherUsageStats false --logger.level info " + command: "cd frontend && uv run streamlit run main.py --server.headless true + --server.address 0.0.0.0 --server.port 3000 --browser.gatherUsageStats + false --logger.level info " plan: 8 replicas: 1 isPublic: true @@ -40,16 +37,16 @@ run: backend: steps: - name: start backend application - command: . ./env && cd backend && uv run uvicorn app:app --port 3000 --host - 0.0.0.0 --workers 2 + command: cd backend && uv run uvicorn app:app --port 3000 --host 0.0.0.0 + --workers 2 plan: 8 replicas: 1 isPublic: false api-docs: steps: - name: deploy docs - command: . ./env && cd backend && uv run uvicorn doc:app_docs --host 0.0.0.0 - --port 3000 --workers 2 + command: cd backend && uv run uvicorn doc:app_docs --host 0.0.0.0 --port 3000 + --workers 2 plan: 8 replicas: 1 isPublic: true