updated README for docker

pull/127/MERGE
13621160019@163.com 2022-02-22 11:43:57 +08:00
parent 2b1e1bc90b
commit 088bf8c607
3 changed files with 59 additions and 32 deletions

33
admin/README.md vendored
View File

@ -25,30 +25,41 @@ nano nginx.conf
``` ```
* Build a Docker image * Build a Docker image
On Windows:
```bash ```bash
cd myems/admin cp -r myems/admin c:\myems-admin
cd c:\myems-admin
docker build -t myems/myems-admin . docker build -t myems/myems-admin .
``` ```
On Linux:
```bash
cp -r myems/admin /myems-admin
cd /myems-admin
docker build -t myems/myems-admin .
```
* Run a Docker container * Run a Docker container
If run on Windows host, bind-mount a share upload file folder at c:\myems-upload to the container If run on Windows host, bind-mount a share upload file folder at c:\myems-upload to the container and also bind-mount nginx.conf
-v parameter must be same with that in myems-api -v parameter for upload folder must be same with that in myems-api
```bash ```bash
docker run -d -p 8001:8001 -v c:\myems-upload:/var/www/html/admin/upload --restart always --name myems-admin myems/myems-admin docker run -d -p 8001:8001 -v c:\myems-upload:/var/www/html/admin/upload -v c:\myems-admin/nginx.conf:/etc/nginx/nginx.conf --restart always --name myems-admin myems/myems-admin
``` ```
If run on Linux host, bind-mount a share upload file folder at /myems-upload to the container If run on Linux host, bind-mount a share upload file folder at /myems-upload to the container and also bind-mount nginx.conf
```bash ```bash
docker run -d -p 8001:8001 -v /myems-upload:/var/www/html/admin/upload --restart always --name myems-admin myems/myems-admin docker run -d -p 8001:8001 -v /myems-upload:/var/www/html/admin/upload -v /myems-admin/nginx.conf:/etc/nginx/nginx.conf --restart always --name myems-admin myems/myems-admin
``` ```
-d Run container in background and print container ID -d Run container in background and print container ID
-p Publish a container's port(s) to the host, 8001:8001 (Host:Container) binds port 8001 (right) of the container to TCP port 8001 (left) of the host machine. -p Publish a container's port(s) to the host, 8001:8001 (Host:Container) binds port 8001 (right) of the container to TCP port 8001 (left) of the host machine.
-v If you use -v or --volume to bind-mount a file or directory that does not yet exist on the Docker host, -v creates the endpoint for you. It is always created as a directory. -v If you use -v or --volume to bind-mount a file or directory that does not yet exist on the Docker host, -v creates the endpoint for you. It is always created as a directory.
--restart Restart policy to apply when a container exits --restart Restart policy to apply when a container exits
--name Assign a name to the container --name Assign a name to the container
If you want to immigrate the image to another computer, If you want to immigrate the image to another computer,
* Export image to tarball file * Export image to tarball file

View File

@ -45,20 +45,6 @@ chmod +x run.sh
In this section, you will install myems-api on Docker. In this section, you will install myems-api on Docker.
* Copy source code to root directory
On Windows:
```bash
cp -r myems/myems-api c:\
cd c:\myems-api
```
On Linux:
```bash
cp -r myems/myems-api /
cd /myems-api
```
* Duplicate example.env file as .env file and modify the .env file * Duplicate example.env file as .env file and modify the .env file
Replace ~~127.0.0.1~~ with real **HOST** IP address. Replace ~~127.0.0.1~~ with real **HOST** IP address.
```bash ```bash
@ -66,9 +52,21 @@ cp example.env .env
``` ```
* Build a Docker image * Build a Docker image
On Windows:
```bash ```bash
cp -r myems/myems-api c:\
cd c:\myems-api
docker build -t myems/myems-api . docker build -t myems/myems-api .
``` ```
On Linux:
```bash
cp -r myems/myems-api /
cd /myems-api
docker build -t myems/myems-api .
```
* Run a Docker container * Run a Docker container
On Windows host, bind-mount a share upload folder at c:\myems-upload to the container, On Windows host, bind-mount a share upload folder at c:\myems-upload to the container,
and also bind-mount the .env to the container: and also bind-mount the .env to the container:

32
web/README.md vendored
View File

@ -73,27 +73,45 @@ nano nginx.conf
```bash ```bash
npm i --unsafe-perm=true --allow-root --legacy-peer-deps npm i --unsafe-perm=true --allow-root --legacy-peer-deps
``` ```
* Build for production with NPM * Build for production with NPM
```bash ```bash
npm run build npm run build
``` ```
* Build a Docker image * Build a Docker image
On Windows:
```bash ```bash
cd myems/web cp -r myems/web c:\myems-web
cd c:\myems-web
docker build -t myems/myems-web . docker build -t myems/myems-web .
``` ```
* Run a Docker container
On Linux:
```bash ```bash
docker run -dp 80:80 --restart always --name myems-web myems/myems-web cp -r myems/web /myems-web
cd /myems-web
docker build -t myems/myems-web .
``` ```
-d Run container in background and print container ID * Run a Docker container
If run on Windows host, bind-mount nginx.conf to the container
```bash
docker run -d -p 80:80 -v c:\myems-web/nginx.conf:/etc/nginx/nginx.conf --restart always --name myems-web myems/myems-web
```
If run on Linux host, bind-mount nginx.conf
```bash
docker run -d -p 80:80 -v /myems-web/nginx.conf:/etc/nginx/nginx.conf --restart always --name myems-web myems/myems-web
```
-p Publish a container's port(s) to the host, 8001:8001 (Host:Container) binds port 8001 (right) of the container to TCP port 8001 (left) of the host machine. -d Run container in background and print container ID
--restart Restart policy to apply when a container exits -p Publish a container's port(s) to the host, 80:80 (Host:Container) binds port 80 (right) of the container to TCP port 80 (left) of the host machine.
--name Assign a name to the container --restart Restart policy to apply when a container exits
--name Assign a name to the container
If you want to immigrate the image to another computer, If you want to immigrate the image to another computer,
* Export image to tarball file * Export image to tarball file