https://github.com/leafney/alpine-puppeteer
Alpine Docker Puppeteer Environment
https://github.com/leafney/alpine-puppeteer
alpine docker pm2 puppeteer
Last synced: 3 months ago
JSON representation
Alpine Docker Puppeteer Environment
- Host: GitHub
- URL: https://github.com/leafney/alpine-puppeteer
- Owner: leafney
- Created: 2019-04-08T03:00:22.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T18:42:30.000Z (over 2 years ago)
- Last Synced: 2025-01-14T15:23:35.977Z (5 months ago)
- Topics: alpine, docker, pm2, puppeteer
- Language: JavaScript
- Homepage:
- Size: 17.6 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### alpine-puppeteer
#### Get Image from Docker Hub
```
$ docker pull leafney/alpine-puppeteer
```#### Run a container for your nodejs app
The main directory of the project in the container is `/app`.
```
$ docker run --name puppet -d -p 8000:8000 -v /home/tiger/node_app:/app leafney/alpine-puppeteer:latest
```If you set the log directory to `/logs` in the PM2 configuration file, you can do this:
```
$ docker run --name puppet -d -p 8000:8000 -v /home/tiger/node_app:/app -v /home/tiger/node_logs:/logs leafney/alpine-puppeteer:latest
```***
#### Node App Demo
##### simplest Express application
Take a simplest Express application as an example. More: [Express "Hello World" example](https://expressjs.com/en/starter/hello-world.html)
Create the project directory:
```
$ mkdir node_app$ cd node_app
```Use `yarn` to init:
```
$ yarn init
```Install needed package `express`.
```
$ yarn add express
```Create the main file of `index.js` in path `/src`.
```
const express = require('express')
const app = express()
const port = 8000app.get('/', (req, res) => res.send('Nodejs App Running in Docker!'))
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
```The default port is `8000`.
Run the app with the following command:
```
$ node src/index.js
```Then, load `http://localhost:8000/` in a browser to see the output.
*****
##### Modify pm2 config file
The `ecosystem.config.js` is `pm2` config file. You need to change the configuration items that have been applied to your project.
```
module.exports = {
apps: [{
name: 'node_app',
script: './src/index.js',
instances: 1,
autorestart: true,
watch: false,
// watch: ["src"],
// ignore_watch: ["node_modules"],
max_memory_restart: '50M',
log_date_format: 'YYYY-MM-DD HH:mm:ss',
out_file: '/logs/puppet_out.log',
error_file: '/logs/puppet_error.log',
env: {
NODE_ENV: 'development'
},
env_production: {
NODE_ENV: 'production'
}
}],
};
```##### Run
Copy all files in the `node_app` directory to the volume directory like `/home/tiger/node_app` and restart the container.
Enjoy it!
*****
#### Change container timezone UTC to CST
If the container name is `puppet`,use command `docker exec puppet utc2cst.sh` to change:
```
$ docker exec puppet utc2cst.sh
[i] change timezone success
Mon Apr 8 01:52:13 CST 2019$ docker restart puppet
puppet
```*****
#### show app status
use `pm2 list` or `pm2 monit` to get app status:
```
docker exec -it puppet pm2 list
# or:
docker exec -it puppet pm2 monit
# (use `q` exit)
```
*****