Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
feat: dockerize (#2)
Browse files Browse the repository at this point in the history
* feat: add docker support

* include sample docker-compose.yml

* feat: load dotenv directly in index.js

* no point in mounting .env to the container

* feat: build workflow

* chore: use ghcr image in docker-compose
  • Loading branch information
przekichane authored Aug 3, 2024
1 parent 70bfc9f commit 1d1090c
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
34 changes: 34 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build

on: push

jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Login to ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: ghcr.io/${{ github.repository }}:latest
platforms: linux/amd64
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:lts-alpine3.20

WORKDIR /app

COPY package.json yarn.lock ./

RUN npm install

COPY . .

CMD ["npm", "run", "start"]
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
bot:
image: ghcr.io/wezuwiusz/wezuwiuszowybot
restart: unless-stopped
env_file:
- .env
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const { Telegraf } = require('telegraf')
const fs = require('fs');

require('dotenv').config()

let catfacts = fs.readFileSync('assets/catfacts.txt').toString('UTF8').split('\n');
let nodiscord = [
'Nie planujemy posiadać Discorda.',
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "WezuwiuszowyBot",
"dependencies": {
"dotenv": "^16.4.5",
"telegraf": "^4.16.3"
},
"scripts": {
"start": "node --env-file=.env index.js"
"start": "node index.js"
}
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ debug@^4.3.4:
dependencies:
ms "2.1.2"

dotenv@^16.4.5:
version "16.4.5"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f"
integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==

event-target-shim@^5.0.0:
version "5.0.1"
resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789"
Expand Down

0 comments on commit 1d1090c

Please sign in to comment.