Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(docker): run in docker, and build scripts for docker #1291

Merged
merged 8 commits into from
Dec 11, 2020
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser \
DOCKER=true

RUN addgroup -S appuser && adduser -S -g appuser appuser \
&& addgroup appuser audio \
&& addgroup appuser video \
egidijus marked this conversation as resolved.
Show resolved Hide resolved
&& mkdir -p /home/appuser/Downloads /app \
&& chown -R appuser:appuser /home/appuser \
&& chown -R appuser:appuser /app
Expand Down
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.DEFAULT_GOAL := go
export all
SHELL := /usr/bin/env bash

go : build run

build:
docker-compose build streetmerchant-shop-bot


run:
docker-compose up
# docker-compose --env-file .env up -d


stop:
docker-compose stop

clean:
docker-compose kill
docker-compose down
docker-compose rm -f
egidijus marked this conversation as resolved.
Show resolved Hide resolved
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '3.0'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
version: '3.0'
version: '3.8'

Let's pin to the latest version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested if this docker-compose is compatible with v3.8 compose file.
these versions are for the docker-compose.yml file, across the versions some add more features at the cost of mandatory complexity.

We can stick with v3.0 of docker-compose file until the end of days (caveat: if we do not need any functionality from greater versions, and do not mind slight change of syntax).

https://docs.docker.com/compose/compose-file/

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay! I can get with that. Since we're pinning to 3.0, that makes sense to me.

services:
streetmerchant-shop-bot:
build:
context: .
dockerfile: Dockerfile
container_name: streetmerchant-shop-bot
hostname: streetmerchant-shop-bot
egidijus marked this conversation as resolved.
Show resolved Hide resolved
# cap_add:
# - CAP_SYS_ADMIN
environment:
- "ENV=dev"
volumes:
- ".env:/app/.env:ro"
egidijus marked this conversation as resolved.
Show resolved Hide resolved
ports:
- 7997:7997
egidijus marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ async function main() {
}

// https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#tips
// https://stackoverflow.com/questions/48230901/docker-alpine-with-node-js-and-chromium-headless-puppeter-failed-to-launch-c
if (config.docker) {
args.push('--disable-dev-shm-usage');
args.push('--no-sandbox');
args.push('--disable-setuid-sandbox');
args.push('--headless');
args.push('--disable-gpu');
}

// Add the address of the proxy server if defined
Expand All @@ -38,7 +43,7 @@ async function main() {
}

await stop();

logger.warn('ℹ printing puppeteer configs::', args);
browser = await puppeteer.launch({
args,
defaultViewport: {
Expand Down