Skip to content

Commit c74ea28

Browse files
authored
fix(docker): run in docker, and build scripts for docker (#1291)
Updates unnecessary need to grant special privileges when running in Docker.
1 parent 67b19a7 commit c74ea28

File tree

5 files changed

+63
-1
lines changed

5 files changed

+63
-1
lines changed

Diff for: Makefile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.DEFAULT_GOAL := run
2+
3+
.PHONY: build
4+
build:
5+
docker-compose build streetmerchant
6+
7+
.PHONY: run
8+
run:
9+
docker-compose up
10+
11+
.PHONY: run-detached
12+
run-detached:
13+
docker-compose up -d
14+
15+
.PHONY: stop
16+
stop:
17+
docker-compose down

Diff for: docker-compose.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: '3.0'
2+
services:
3+
streetmerchant:
4+
build:
5+
context: .
6+
dockerfile: Dockerfile
7+
container_name: streetmerchant
8+
env_file: .env
9+
# ports:
10+
# - 7997:7997

Diff for: docs/docker.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Docker
2+
3+
You will need:
4+
* `docker` (tested on Docker version 19.03.13-ce, build 4484c46d9d)
5+
* `make` (not a strict requirement, but helps out with stages)
6+
* `docker-compose` (tested on docker-compose version 1.27.4,)
7+
8+
## What
9+
It is assumed you know what docker is.
10+
You can build and run this project inside docker, headless. All the depencies will be downloaded in to the docker image.
11+
12+
## Why
13+
There is no need to install node, or anything else (apart from above) on your machine to run this.
14+
15+
## How
16+
17+
1. Copy pasta the `.env-example` in to `.env`.
18+
2. Edit `.env` in your favourite editor, pick stores, options what ever you want.
19+
3. If you have make, simply run `make` in your terminal to get started. You should see a docker build, and container start automatically.
20+
4. If you want a webserver running, so you can edit the options via web interface, uncomment lines 13-14 in `docker-compose.yml` to open up ports `7997`. Update `.env` file `WEB_PORT="7997"` this is so the service listens on `7997` and we expose the same ports on docker.
21+
5. If you do not have make, because windows, run these commands in order:
22+
```
23+
docker-compose build streetmerchant-shop-bot
24+
docker-compose up
25+
```

Diff for: docs/getting-started.md

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ docker run --cap-add=SYS_ADMIN \
5353

5454
To customize streetmerchant, make a copy of `dotenv-example` as `dotenv` and make any changes to your liking. View [Reference](reference/application.md) for more information on variables and their usage.
5555

56+
57+
## Building docker
58+
59+
[Docker-Docs](docs/docker.md)
60+
5661
???+ tip
5762
All environment variables are optional.
5863

Diff for: src/index.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ async function main() {
2626
}
2727

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

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

4045
await stop();
41-
46+
logger.warn('ℹ printing puppeteer configs::', args);
4247
browser = await puppeteer.launch({
4348
args,
4449
defaultViewport: {

0 commit comments

Comments
 (0)