diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index de6e4dd..3c7ad1e 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -38,3 +38,41 @@ jobs: git add . git commit -m "Update from Back-End (Automation)" git push origin main + + deployVPSCA: + + runs-on: ubuntu-latest + + name: Deploy to VPS CA + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '18.X' + + - name: Install dependencies + run: npm install + + - name: Build + run: npm run build + + - name: Deploy to VPS CA + uses: easingthemes/ssh-deploy@main + with: + SSH_PRIVATE_KEY: ${{ secrets.VPS_CA_SSH }} + ARGS: "-rlgoDzvc --delete" + REMOTE_HOST: ${{ secrets.VPS_CA_HOST }} + REMOTE_USER: ${{ secrets.VPS_CA_USERNAME }} + TARGET: ${{ secrets.VPS_CA_TARGET }} + EXCLUDE: "/node_modules/" + SCRIPT_AFTER: | + echo "DB_NAME=\"${{ secrets.BACKEND_DB_NAME }}\"" >> ${{ secrets.VPS_CA_TARGET }}.env + echo "DB_URL=\"${{ secrets.BACKEND_DB_URL }}\"" >> ${{ secrets.VPS_CA_TARGET }}.env + echo "SALT_HASH=\"${{ secrets.BACKEND_SALT }}\"" >> ${{ secrets.VPS_CA_TARGET }}.env + sleep 2 + ./restartBackend.sh + SCRIPT_AFTER_REQUIRED: true diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..36cc7bf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM node:18 +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build +EXPOSE 3000 +CMD ["npm", "run", "start:prod"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b01dfa2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: "3.8" +services: + backend: + container_name: backend + build: . + ports: + - "3000:3000" + volumes: + - .:/app + - /app/node_modules + command: npm run start:prod