优化部署脚本

main
franktrue 3 years ago
parent 7dd506c624
commit c3fe7e41a2

@ -18,9 +18,9 @@ steps:
hosts: # 多个ip使用,隔开 hosts: # 多个ip使用,隔开
from_secret: ssh_host from_secret: ssh_host
# 来源目录 # 来源目录
source: ./api2gpt-mid source: ./api2gpt-mid,deplpy/
# 目标服务器目录 # 目标服务器目录
target: /mnt/data/wwwroot/api2gpt/mid target: /mnt/data/wwwroot/api2gpt/mid
script: script:
- cd /mnt/data/wwwroot/api2gpt/mid - cd /mnt/data/wwwroot/api2gpt/mid
- ./api2gpt-mid - docker-compose up -d --build

@ -1,5 +1,5 @@
# Build step # Build step
FROM golang:1.18 AS builder FROM golang:1.18-alpine AS builder
ENV GOPROXY=https://goproxy.cn,direct ENV GOPROXY=https://goproxy.cn,direct
RUN mkdir -p /build RUN mkdir -p /build
WORKDIR /build WORKDIR /build
@ -14,5 +14,5 @@ RUN set -x && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -
EXPOSE 8080 EXPOSE 8080
WORKDIR /app WORKDIR /app
COPY --from=builder /build/main /app/api2u-go COPY --from=builder /build/main /app/api2gpt-mid
ENTRYPOINT ["/app/api2u-go"] ENTRYPOINT ["/app/api2gpt-mid"]

@ -1,11 +1,11 @@
## docker 打包镜像 ## docker 打包镜像
docker stop api2u-go docker stop aapi2gpt-mid
docker rm api2u-go docker rm aapi2gpt-mid
docker build -t api2u-go . docker build -t aapi2gpt-mid .
## docker 运行镜像 ## docker 运行镜像
docker run -d -p 8081:8080 --name=api2u-go --env REDIS_ADDRESS=172.17.0.1:6379 api2u-go docker run -d -p 8081:8080 --name=aapi2gpt-mid --env REDIS_ADDRESS=172.17.0.1:6379 aapi2gpt-mid
docker run -p 8081:8080 --name=api2u-go --env REDIS_ADDRESS=172.17.0.1:6379 api2u-go docker run -p 8081:8080 --name=aapi2gpt-mid --env REDIS_ADDRESS=172.17.0.1:6379 aapi2gpt-mid

@ -0,0 +1,13 @@
FROM alpine:latest
WORKDIR /app
# 更新安装源
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk update && apk add --no-cache bash supervisor
RUN adduser -S -D -H -h /app -s /sbin/nologin -u 1000 app
RUN chown -R app /app
ADD server /app/server
ADD work.ini /etc/supervisor.d/
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]

@ -0,0 +1,14 @@
version: "3"
services:
server:
build:
context: .
dockerfile: Dockerfile
container_name: api2gpt-mid
environment:
# 时区上海
TZ: Asia/Shanghai
privileged: true
restart: always
ports:
- 8082:8080

@ -0,0 +1,11 @@
[supervisord]
nodaemon=true
loglevel=debug
[program:api2gpt-mid]
priority=1
directory=/app/server/
command=/app/server/api2gpt-mid
user=app
autostart=true
autorestart=true
Loading…
Cancel
Save