fix: docker build

This commit is contained in:
Innei
2023-06-09 12:12:19 +08:00
committed by GitHub
parent 3e484394c4
commit 944c571210
5 changed files with 23 additions and 5 deletions

View File

@@ -46,7 +46,6 @@ const commander = program
.option(
'--encrypt_enable',
'enable encrypt security field, please remember encrypt key.',
false,
)
.option(
'--encrypt_algorithm <string>',

View File

@@ -4,10 +4,14 @@ services:
app:
container_name: mx-server
image: innei/mx-server:latest
command: node index.js --redis_host=redis --db_host=mongo --allowed_origins=${ALLOWED_ORIGINS} --jwt_secret=${JWT_SECRET} --color --encrypt_key=${ENCRYPT_KEY} --encrypt_enable=${ENCRYPT_ENABLE}
command: sh ./docker-run.sh
environment:
- TZ=Asia/Shanghai
- NODE_ENV=production
- ALLOWED_ORIGINS
- JWT_SECRET
- ENCRYPT_KEY
- ENCRYPT_ENABLE
volumes:
- ./data/mx-space:/root/.mx-space
ports:

16
docker-run.sh Normal file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
command="node index.js --redis_host=redis --db_host=mongo \
--allowed_origins=${ALLOWED_ORIGINS} \
--jwt_secret=${JWT_SECRET} \
--color"
if [ -n "$ENCRYPT_KEY" ]; then
command+=" --encrypt_key=${ENCRYPT_KEY}"
fi
if [ "$ENCRYPT_ENABLE" = "true" ]; then
command+=" --encrypt_enable "
fi
exec $command

View File

@@ -14,6 +14,7 @@ RUN apk add zip unzip mongodb-tools bash fish rsync jq curl --no-cache
WORKDIR /app
COPY --from=builder /app/out .
COPY --from=builder /app/assets ./assets
COPY ./docker-run.sh .
ENV TZ=Asia/Shanghai
EXPOSE 2333

View File

@@ -18,9 +18,7 @@ if [[ $? -ne 0 ]]; then
exit 1
fi
curl https://cdn.jsdelivr.net/gh/mx-space/mx-server@master/docker-compose.yml >docker-compose.yml
docker-compose up -d
(docker-compose up &)
if [[ $? -ne 0 ]]; then
echo "failed to run docker-compose instance"