Skip to content

Commit

Permalink
docs: add Docker deployment guide
Browse files Browse the repository at this point in the history
fix: some Shell Command bugs
  • Loading branch information
TechQuery committed Oct 6, 2023
1 parent 8fc5dd8 commit a8c4f95
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-oss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ jobs:
command: |
cd /tmp
mv docker-compose.yml .env start-docker.sh ~/
cd ~/
chmod +x ~/start-docker.sh
sudo ~/start-docker.sh ${{ env.ARTIFACT_PATH }}
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ COPY package.json package-lock.json file-content-injector.js /home/node/app/
RUN npm i

COPY . /home/node/app
RUN npm run build

RUN npm prune --production || true \
npm cache clean -f
Expand Down
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,63 @@ These two services are very much alike. In fact, `Polyfiller` depends on the lib
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.
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`.

#### Docker

> This guide has been tested in the deployment process of China mirror: https://polyfiller.kaiyuanshe.cn
##### Simple container

Run shown commands in the Project Root folder:

```shell
docker build -t polyfiller/api-service .
docker run --name polyfiller -e NODE_ENV=production -p 3000:3000 polyfiller/api-service
```

##### Composed services with Object Storage

Install Docker plugins in Cloud Server at first:

```shell
sudo apt install docker-compose
sudo docker plugin install juicedata/juicefs
```

###### 1. Manual deployment

1. Write [JuiceFS environment variables](https://juicefs.com/docs/community/juicefs_on_docker/#using-docker-compose) into `.env` file in the Project Root folder:

```ini
STORAGE_TYPE =
BUCKET =
ACCESS_KEY =
SECRET_KEY =
```

2. Run shown commands in the Project Root folder:

```shell
docker-compose up -d
```

###### 2. Automatic deployment

1. Set GitHub Repository secrets:

| name | value |
| :--------: | :-------------------------------: |
| `ENV_FILE` | `.env` file shown above |
| `HOST` | IP or Domain Name of Cloud Server |
| `USER` | Account Name of Cloud Server |
| `SSH_KEY` | SSH Private Key of Cloud Server |

2. Push a Git tag:

```shell
git tag v0.2.3-oss # the version number is the value of "version" field in "package.json"
git push origin --tags
```

## Logo

All credits go to [Andreas Mehlsen (@andreasbm)](https://github.com/andreasbm/) for the awesome logo design.
Expand Down
4 changes: 2 additions & 2 deletions start-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
docker load < $1
docker image ls -a

docker compose down
docker compose up -d
docker-compose down --volumes
docker-compose up -d

docker image prune -a -f

0 comments on commit a8c4f95

Please sign in to comment.