Skip to content

Commit eba898f

Browse files
committed
add s3 docker
1 parent 75a6e34 commit eba898f

File tree

12 files changed

+89
-17
lines changed

12 files changed

+89
-17
lines changed

.github/workflows/spa-server-docker-cd.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ jobs:
1414
- uses: actions/checkout@v3
1515
with:
1616
submodules: true
17-
-
18-
name: Set up QEMU
19-
uses: docker/setup-qemu-action@v1
17+
# -
18+
# name: Set up QEMU
19+
# uses: docker/setup-qemu-action@v1
2020
-
2121
name: Set up Docker Buildx
2222
uses: docker/setup-buildx-action@v1
@@ -27,12 +27,19 @@ jobs:
2727
username: ${{ secrets.DOCKERHUB_USERNAME }}
2828
password: ${{ secrets.DOCKERHUB_TOKEN }}
2929
-
30-
name: Build and push
30+
name: build and push spa-server
3131
uses: docker/build-push-action@v2
3232
with:
3333
context: .
34-
platforms: linux/amd64,linux/arm64
34+
#platforms: linux/amd64,linux/arm64
3535
push: true
3636
cache-from: type=gha
3737
cache-to: type=gha,mode=max
38-
tags: timzaak/spa-server:${{github.event.inputs.version}}
38+
tags: timzaak/spa-server:${{github.event.inputs.version}}
39+
40+
- name: build and push spa-server with S3
41+
with:
42+
context: ./docker
43+
file: S3FS.Dockerfile
44+
push: true
45+
tags: timzaak/spa-server:${{github.event.inputs.version}}-s3

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ ifeq ($(VERSION), )
4040
else
4141
DOCKER_BUILDKIT=1 docker build . -t="timzaak/spa-server:$(VERSION)"
4242
docker push timzaak/spa-server:$(VERSION)
43+
cd docker
44+
DOCKER_BUILDKIT=1 docker build . -f S3FS.Dockerfile -t="timzaak/spa-server:$(VERSION)-s3"
45+
docker push timzaak/spa-server:$(VERSION)-s3
4346
endif
4447

4548
spa-client-docker-release:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ It is to provide a static web http server with cache and hot reload.
1111
- Hot reload support(Mac and Linux).
1212
- CORS support.
1313
- Http auto redirect to https.
14-
- Docker support(compressed size: 32M).
14+
- Docker support(compressed size: 32M), and support S3 as storage by S3FS.
1515
- Provide command line/npm package to deploy spa.
1616
- Multiple configs for different domain.
1717

README_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- 支持热更新(Mac and Linux)。
1111
- 支持 CORS 跨域
1212
- http/https 同时服务(http 也可返回 redirect https)。
13-
- 支持 Docker 镜像(压缩后大小:32M)
13+
- 支持 Docker 镜像(压缩后大小:32M), 并通过S3FS 支持 S3 作为数据存储
1414
- 提供 命令行/npm包 客户端,一行命令部署
1515
- 每个域名可拥有独立的配置
1616

docker/S3FS.Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ARG BASE_IMAGE=timzaak/spa-server
2+
ARG VERSION=1.2.5
3+
4+
FROM ${BASE_IMAGE}:${VERSION} as Source
5+
6+
7+
FROM panubo/s3fs:1.84
8+
COPY --from=Source ./config.conf .
9+
COPY --from=Source ./spa-server .
10+
11+
COPY entry.sh /entry.sh
12+
13+
ENTRYPOINT ["/entry.sh"]

docker/entry.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
# This is FROM S3FS
3+
set -e
4+
[ "${DEBUG:-false}" == 'true' ] && { set -x; S3FS_DEBUG='-d -d'; }
5+
6+
# Defaults
7+
: ${AWS_S3_AUTHFILE:='/root/.s3fs'}
8+
: ${AWS_S3_MOUNTPOINT:='/mnt'}
9+
: ${AWS_S3_URL:='https://s3.amazonaws.com'}
10+
: ${S3FS_ARGS:=''}
11+
12+
# If no command specified, print error
13+
[ "$1" == "" ] && set -- "$@" bash -c 'echo "Error: Please specify a command to run."; exit 128'
14+
15+
# Configuration checks
16+
if [ -z "$AWS_STORAGE_BUCKET_NAME" ]; then
17+
echo "Error: AWS_STORAGE_BUCKET_NAME is not specified"
18+
exit 128
19+
fi
20+
21+
if [ ! -f "${AWS_S3_AUTHFILE}" ] && [ -z "$AWS_ACCESS_KEY_ID" ]; then
22+
echo "Error: AWS_ACCESS_KEY_ID not specified, or ${AWS_S3_AUTHFILE} not provided"
23+
exit 128
24+
fi
25+
26+
if [ ! -f "${AWS_S3_AUTHFILE}" ] && [ -z "$AWS_SECRET_ACCESS_KEY" ]; then
27+
echo "Error: AWS_SECRET_ACCESS_KEY not specified, or ${AWS_S3_AUTHFILE} not provided"
28+
exit 128
29+
fi
30+
31+
# Write auth file if it does not exist
32+
if [ ! -f "${AWS_S3_AUTHFILE}" ]; then
33+
echo "${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}" > ${AWS_S3_AUTHFILE}
34+
chmod 400 ${AWS_S3_AUTHFILE}
35+
fi
36+
37+
echo "==> Mounting S3 Filesystem"
38+
mkdir -p ${AWS_S3_MOUNTPOINT}
39+
40+
# s3fs mount command
41+
s3fs $S3FS_DEBUG $S3FS_ARGS -o passwd_file=${AWS_S3_AUTHFILE} -o url=${AWS_S3_URL} ${AWS_STORAGE_BUCKET_NAME} ${AWS_S3_MOUNTPOINT}
42+
43+
exec /spa-server

docs/.vitepress/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function getGuideSidebar() {
5151
text: 'SPA-Server', children: [
5252
{text: 'Configuration', link: '/guide/spa-server-configuration'},
5353
{text: 'Http API', link: '/guide/spa-server-api'},
54-
{text: 'Package', link: '/guide/spa-server-release-pacakge'},
54+
{text: 'Package', link: '/guide/spa-server-release-package'},
5555
]
5656
},
5757
{

docs/develop/roadmap.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ There is no real roadmap for v1.3.x now, need users firstly.
55

66
### near future before v1.3.0
77
- [ ] CD: release triggered by new tag
8-
- [ ] CD: add wix configs, and release window msi package for spa-client(need window pc to do this)
98
- [ ] TEST: test integrate, and add ci to run it
10-
- [ ] Feat: S3 Support
119

1210
### Version v1.2.6
1311
- [ ] doc: add spa-server usage scenario and corresponding config File
1412
- [ ] doc: what's version control and file directory layout
1513
- [ ] chore: spa-client command help doc
14+
- [ ] bench: add benchmark
15+
- [x] feat: Support S3 by docker(backward: release docker timzaak/spa-server:1.2.5-s3)
16+
- [x] deps: bump hocon 0.9, fix size unit config parse
1617
- [x] fix(build): disable generating new tag when build spa-client(js) success
17-
- [x] doc: add algolia search, thanks for algolia company!
18+
- [x] doc: add algolia search, thanks for algolia company!
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# spa-server distribution package
22
## Docker Image
3-
The docker image is distributed at `Docker Hub` as `timzaak/spa-server`, it support `linux/amd64`,`linux/arm64`.
3+
The docker image is distributed at `Docker Hub` as `timzaak/spa-server`.
4+
5+
### AWS S3 Support
6+
We support S3 storage by docker `panubo/docker-s3fs`, and release as `timzaak/spa-server:${version}-s3`, all configure about S3fs fuse can be found [here](https://github.com/panubo/docker-s3fs).
47

58
## From Code
69
There no plan to release binary package. You can `git clone` the code and build yourself.

server/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ serde_repr = "0.1"
5050
#cache
5151
dashmap = "5.2"
5252

53+
#s3
54+
#rust-s3 = {version="0.31", features = ["blocking", "tokio-rustls-tls"], default-features = false}
55+
5356
# util
5457
md-5 = "0.10"
5558
regex = "1.5"

0 commit comments

Comments
 (0)