diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..edd83c0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules +npm-debug.log +Dockerfile +.dockerignore \ No newline at end of file diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..6f20283 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,32 @@ +name: CI + +on: + push: + branches: ['master'] + +jobs: + deploy: + name: Deploy to VPS + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: executing remote ssh commands using password + uses: appleboy/ssh-action@v0.1.10 + with: + host: ${{ secrets.SSH_IP }} + username: ${{ secrets.SSH_USERNAME }} + password: ${{ secrets.SSH_PASSWORD }} + port: ${{ secrets.SSH_PORT }} + script: | + cd unisafka-discord + rm -rf unisafka-discord + git clone https://github.com/KasperiP/unisafka-discord.git + cp .env unisafka-discord/.env + cd unisafka-discord + docker stop unisafka-discord + docker rm unisafka-discord + docker build -t unisafka-discord . + docker run -d --restart=always --name unisafka-discord unisafka-discord diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a9be8f1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +# Use the official Node.js LTS (Long Term Support) image as the base image +FROM node:20-alpine + +# Set the working directory inside the container +WORKDIR /usr/src/app + +# Copy the package.json and package-lock.json (if you have it) to the working directory +COPY package*.json ./ + +# Install Node.js dependencies +RUN npm install + +# Copy the rest of your application's source code to the container +COPY . . + +# Define the command to run your Node.js application +CMD ["node", "main.js"] \ No newline at end of file