diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..37e60dd --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,22 @@ +name: Deploy docker image + +on: + push: + tags: + - '*' + +jobs: + publish-docker-image: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build the Docker image + run: | + docker build . --tag ghcr.io/surftimer/surftimer-discord-bot:latest + docker push ghcr.io/surftimer/surftimer-discord-bot:latest diff --git a/Dockerfile b/Dockerfile index 36ffb20..1c56ac6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,4 +11,4 @@ RUN git clone https://github.com/Sarrus1/SurfTimer-Discord-Bot.git . RUN npm i && npm run build -CMD npm run start \ No newline at end of file +CMD ["npm", "run", "start"] \ No newline at end of file diff --git a/README.md b/README.md index a88bd41..12b9075 100644 --- a/README.md +++ b/README.md @@ -32,17 +32,14 @@ It uses the [discord.js](https://discord.js.org/#/) library and the [prisma ORM] ## How to use it -### Using Docker (recommended) +### Using Docker (Easy and Recommended) 1. Install [Docker](https://docs.docker.com/engine/install/ubuntu/). 2. Create a directory called `SurfTimer-Bot` --- `mkdir SurfTimer-Bot` -3. In this directory, create a file named `Dockerfile` --- `nano SurfTimer-Bot/Dockerfile`. -4. In this file, paste the contents of [this file](https://raw.githubusercontent.com/Sarrus1/SurfTimer-Discord-Bot/main/Dockerfile). -5. In the same directory, create a file named `.env` --- `nano SurfTimer-Bot/.env` -6. In this file, paste the contents of [this file](https://raw.githubusercontent.com/Sarrus1/SurfTimer-Discord-Bot/main/env_sample.txt). -7. Edit the environment variables accordingly (follow the URL for a detailed guide). -8. Run the following command to build the Docker image: `docker build SurfTimer-Bot/ -t surftimer-bot` -9. Now run the container with the following command: `docker run -d --env-file=SurfTimer-Bot/.env surftimer-bot` +3. In this directory, create a file named `docker-compose.yml` --- `nano docker-compose.yml`. +4. In this `docker-compose.yml`, copy/paste the contents of [this file](https://raw.githubusercontent.com/surftimer/SurfTimer-Discord-Bot/main/docker-compose.yml). +5. In this `docker-compose.yml`, edit the environment variables accordingly (follow the URL for a detailed guide). +6. Now run the container with `docker compose up -d`. ### Using Node.js diff --git a/docker-compose.yml b/docker-compose.yml index 5f7e3cb..b72a2ee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.8' services: surftimer-bot: - build: ./ + image: ghcr.io/surftimer/surftimer-discord-bot:latest restart: always environment: # Discord token (https://discordjs.guide/preparations/setting-up-a-bot-application.html#creating-your-bot)