Skip to content

Commit

Permalink
feat/deploy docker image (#249)
Browse files Browse the repository at this point in the history
* feat: mongodb env file

* gitignore: add mongodb env

* update readme

* docker: update docker files

* feat: cd dockerhub
  • Loading branch information
JustDams authored Feb 6, 2023
1 parent 58c3919 commit cc8ca56
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 26 deletions.
9 changes: 0 additions & 9 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,5 @@ STEAM_TOKEN=
# TopGG Api Token (not required)
TOPGG_TOKEN=

# Mongo root username
MONGO_INITDB_ROOT_USERNAME=app_user

# Mongo root password
MONGO_INITDB_ROOT_PASSWORD=app_password

# Name of the init database
MONGO_INITDB_DATABASE=faceitFinder

# Database URI (change if needed)
MONGO_URI=mongodb://app_user:app_password@faceitfinder_mongodb:27017/faceitFinder?authSource=admin
8 changes: 8 additions & 0 deletions .env.mongodb.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Mongo root username
MONGO_INITDB_ROOT_USERNAME=app_user

# Mongo root password
MONGO_INITDB_ROOT_PASSWORD=app_password

# Name of the init database
MONGO_INITDB_DATABASE=faceitFinder
33 changes: 33 additions & 0 deletions .github/workflows/dockerhub-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish Docker image

on:
push:
branches: ["release"]

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: justdams/faceitfinder-discordbot

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ typings/
.env
.env.local
.env.test
.env.mongodb

# parcel-bundler cache (https://parceljs.org/)
.cache
Expand Down
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ FROM node:17.9.0

ENV APP /usr/src/app

ENV NODE_ENV=
ENV TOKEN=
ENV FACEIT_TOKEN=
ENV STEAM_TOKEN=
ENV TOPGG_TOKEN=
ENV MONGO_URI=

RUN mkdir -p $APP
WORKDIR $APP

Expand Down
52 changes: 40 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
# FaceitFinder
## _Discord Bot which permit to find a faceit profile & its stats from a Steam id_
[![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.com/) [![Docker](https://badgen.net/badge/icon/docker?icon=docker&label)](https://docker.com/) [![Gitmoji](https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67.svg)](https://gitmoji.dev/)
## _Discord Bot which permit to find a faceit profile & its stats from different parameters_
[![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.com/) [![Docker](https://badgen.net/badge/icon/docker?icon=docker&label)](https://docker.com/)

## Features

- Retrieve a Faceit account using a Steam ID, Steam UID, Steam profile link, in-game status or by mentioning a Discord user who has linked to a Faceit account.
- Get an elo graph.
- Get statistics from the last game.
- Link a Discord account whith a Faceit profile to get his statistics easily.
- Retrieve a Faceit account using a **Steam ID**, **Steam UID**, **Steam profile link**, **in-game status**, **Faceit username** or by **mentioning a Discord user** who has linked to a Faceit account.

## Development

Want to contribute? Great!

### Installation
### Run docker on a dev environment

**Clone the repository:**

Expand All @@ -22,24 +19,55 @@ git clone git@github.com:JustDams/faceitFinder.git
cd faceitFinder
```

Rename the `.env.example` to `.env` and complete/update it with your information.
**Setup env files:**

**Run docker on a dev environment:**
Copy the `.env.example` in `.env` and `.env.mongodb.example` in `.env.mongodb` then complete/update it with your information.

```sh
cp .env.example .env
cp .env.mongodb.example .env.mongodb
```

**Run compose:**

```sh
docker-compose -f docker-compose.dev.yml up
```

**Run linter:**
**To run the linter:**

```sh
docker exec -it faceitfinder_dev npm run lint
```

**Run docker on a prod environment:**
### Run docker on a prod environment

**Clone the repository:**

```sh
git clone git@github.com:JustDams/faceitFinder.git
cd faceitFinder
```

**Got to the prod branch:**

```sh
git checkout prod
```

**Setup env files:**

Copy the `.env.example` in `.env` and `.env.mongodb.example` in `.env.mongodb` then complete/update it with your information.

```sh
cp .env.example .env
cp .env.mongodb.example .env.mongodb
```

**Run compose:**

```sh
docker-compose -f docker-compose.prod.yml up
docker-compose -f docker-compose.prod.yml up --build -d
```

## License
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:
volumes:
- ~/mongo-volume:/data/db
env_file:
- .env
- .env.mongodb
networks:
- app

Expand Down
6 changes: 2 additions & 4 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
version: '3'
services:
app:
build:
context: .
dockerfile: Dockerfile
image: justdams/faceitfinder-discordbot:latest
restart: on-failure
container_name: faceitfinder_prod
command: npm start
Expand All @@ -29,7 +27,7 @@ services:
volumes:
- ~/mongo-volume:/data/db
env_file:
- .env
- .env.mongodb
networks:
- app

Expand Down

0 comments on commit cc8ca56

Please sign in to comment.