diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..1bcf75a3f65b57725abe3ff844a2c3869cab61f5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +docker-compose.yml +Dockerfile +.gitignore +README.md +.drone.yml \ No newline at end of file diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000000000000000000000000000000000000..8f771e99d7d335bfc1a5753e2c947377cab3af03 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,120 @@ +kind: pipeline +type: docker +name: deploy + +clone: + disable: true + +steps: +- name: notif build start + image: appleboy/drone-discord + settings: + webhook_id: + from_secret: discord_webhook_id + webhook_token: + from_secret: discord_webhook_token + username: "Drone Princelle (ERP: student)" + avatar_url: https://s3.princelle.org/share/drone-ci.png + message: > + 🚀 Starting deployment of **{{ repo.name }}** repo (*ERP*)... + + + **Commit from {{commit.author}} on {{commit.branch}}:** + + {{commit.message}} + + {{ build.link }} + + +- name: pull + image: appleboy/drone-ssh + settings: + host: flash.princelle.org + username: mprincelle + port: 22 + key: + from_secret: ci_key + script: + - cd /app/uni/erp/student + - git fetch --all + - git reset --hard origin/main + - git checkout {{commit.branch}} + - git pull + +- name: configure + image: appleboy/drone-ssh + settings: + host: flash.princelle.org + username: mprincelle + port: 22 + key: + from_secret: ci_key + script: + - cd /app/uni/erp/student + - echo -e "DB_PORT=2005" > .env + - echo -e "SERVER_PORT=2003" >> .env + +- name: build + image: appleboy/drone-ssh + settings: + host: flash.princelle.org + username: mprincelle + port: 22 + key: + from_secret: ci_key + script: + - cd /app/uni/erp/student + - docker-compose up -d --build + + +- name: notif deploy done + image: appleboy/drone-discord + settings: + webhook_id: + from_secret: discord_webhook_id + webhook_token: + from_secret: discord_webhook_token + username: "Drone Princelle (ERP: student)" + avatar_url: https://s3.princelle.org/share/drone-ci.png + message: > + ✅ Successfully deployed **{{ repo.name }}** repo (*ERP*) on Princelle Cloud! + + + **Commit from {{commit.author}} on {{commit.branch}}:** + + {{commit.message}} + + **APP URL:** https://student.erp.uni.princelle.org/ + + {{ build.link }} + when: + status: + - success + +- name: notif deploy failure + image: appleboy/drone-discord + settings: + webhook_id: + from_secret: discord_webhook_id + webhook_token: + from_secret: discord_webhook_token + username: "Drone Princelle (ERP: student)" + avatar_url: https://s3.princelle.org/share/drone-ci.png + message: > + âš ï¸ Error on deploying **{{ repo.name }}** repo (*ERP*) on Princelle Cloud... + + + **Commit from {{commit.author}} on {{commit.branch}}:** + + {{commit.message}} + + {{ build.link }} + when: + status: + - failure + + +trigger: + branch: + - main + - feature/docker-env diff --git a/.env.model b/.env.model new file mode 100644 index 0000000000000000000000000000000000000000..a8472f79e22024ca4d64f04087b14b1962a6f8cd --- /dev/null +++ b/.env.model @@ -0,0 +1,2 @@ +SERVER_PORT=27017 +APP_PORT=8005 \ No newline at end of file diff --git a/.gitignore b/.gitignore index aba02a1184a2ab6ad2eeb5643516ef6a7351b0d0..8ea5b1e335694ebd1ab4f3ec896a08598b9bcc2b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .idea/ +.env \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 4b9aa12c411aa9c4dd41212efa0fcee488703a18..c234c8cd2d882bdd7d43d74f7fcc4af16d5f2fe8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,19 +2,26 @@ version: '3' services: mongodb: image: mongo + container_name: "student_db" + volumes: + - student_db_data:/data/db ports: - - "27017:27017" + - "${DB_PORT:-27017}:27017" server: build: . depends_on: - "mongodb" command: "npm run start:prod" + container_name: "student_app" ports: - - "8005:8005" + - "${SERVER_PORT:-8005}:8005" environment: - CHOKIDAR_USEPOLLING=true - CI=true - NODE_ENV=production - PORT=8005 - MONGO_NAME=mongodb + +volumes: + student_db_data: \ No newline at end of file