Skip to content

Commit

Permalink
feat: CD/CI docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarrus1 committed Nov 25, 2022
1 parent c66ac33 commit 69f7929
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
CMD ["npm", "run", "start"]
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 69f7929

Please sign in to comment.