Skip to content

Commit a8c4f95

Browse files
committed
docs: add Docker deployment guide
fix: some Shell Command bugs
1 parent 8fc5dd8 commit a8c4f95

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-2
lines changed

.github/workflows/deploy-oss.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,6 @@ jobs:
5959
command: |
6060
cd /tmp
6161
mv docker-compose.yml .env start-docker.sh ~/
62+
cd ~/
6263
chmod +x ~/start-docker.sh
6364
sudo ~/start-docker.sh ${{ env.ARTIFACT_PATH }}

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ COPY package.json package-lock.json file-content-injector.js /home/node/app/
1111
RUN npm i
1212

1313
COPY . /home/node/app
14+
RUN npm run build
1415

1516
RUN npm prune --production || true \
1617
npm cache clean -f

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,63 @@ These two services are very much alike. In fact, `Polyfiller` depends on the lib
362362
The server is built with support for both HTTP2 and HTTP. The environment variable `HTTP2=[true|false]` decides whether a HTTP2 server will be hosted or not.
363363
If you use a load balancer and something like `nginx` in a reverse proxy setup, please know that `nginx` doesn't support HTTP2 via its proxy module, so you have to use HTTP1.1 there. Thankfully, it is as easy as setting `HTTP2=false` before launching the server and setting `HTTPS=false`.
364364

365+
#### Docker
366+
367+
> This guide has been tested in the deployment process of China mirror: https://polyfiller.kaiyuanshe.cn
368+
369+
##### Simple container
370+
371+
Run shown commands in the Project Root folder:
372+
373+
```shell
374+
docker build -t polyfiller/api-service .
375+
docker run --name polyfiller -e NODE_ENV=production -p 3000:3000 polyfiller/api-service
376+
```
377+
378+
##### Composed services with Object Storage
379+
380+
Install Docker plugins in Cloud Server at first:
381+
382+
```shell
383+
sudo apt install docker-compose
384+
sudo docker plugin install juicedata/juicefs
385+
```
386+
387+
###### 1. Manual deployment
388+
389+
1. Write [JuiceFS environment variables](https://juicefs.com/docs/community/juicefs_on_docker/#using-docker-compose) into `.env` file in the Project Root folder:
390+
391+
```ini
392+
STORAGE_TYPE =
393+
BUCKET =
394+
ACCESS_KEY =
395+
SECRET_KEY =
396+
```
397+
398+
2. Run shown commands in the Project Root folder:
399+
400+
```shell
401+
docker-compose up -d
402+
```
403+
404+
###### 2. Automatic deployment
405+
406+
1. Set GitHub Repository secrets:
407+
408+
| name | value |
409+
| :--------: | :-------------------------------: |
410+
| `ENV_FILE` | `.env` file shown above |
411+
| `HOST` | IP or Domain Name of Cloud Server |
412+
| `USER` | Account Name of Cloud Server |
413+
| `SSH_KEY` | SSH Private Key of Cloud Server |
414+
415+
2. Push a Git tag:
416+
417+
```shell
418+
git tag v0.2.3-oss # the version number is the value of "version" field in "package.json"
419+
git push origin --tags
420+
```
421+
365422
## Logo
366423

367424
All credits go to [Andreas Mehlsen (@andreasbm)](https://github.com/andreasbm/) for the awesome logo design.

start-docker.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
docker load < $1
44
docker image ls -a
55

6-
docker compose down
7-
docker compose up -d
6+
docker-compose down --volumes
7+
docker-compose up -d
88

99
docker image prune -a -f

0 commit comments

Comments
 (0)