docker fix
This commit is contained in:
@@ -1,19 +1,41 @@
|
|||||||
# 编译阶段
|
# 编译阶段
|
||||||
FROM golang:1.24 AS stage0
|
FROM golang:1.24 AS builder
|
||||||
RUN go env -w GOPROXY=https://proxy.golang.com.cn,https://goproxy.cn,direct
|
|
||||||
ADD ./ /src/ai-chat-backend
|
|
||||||
WORKDIR /src/ai-chat-backend
|
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ai-chat-backend cmd/*.go
|
|
||||||
|
|
||||||
FROM alpine:3.18 AS stage1
|
ENV CGO_ENABLED=0 \
|
||||||
ADD ./curl-amd64 /usr/bin/curl
|
GOOS=linux \
|
||||||
|
GOARCH=amd64 \
|
||||||
|
GOPROXY=https://goproxy.cn|https://proxy.golang.google.cn|direct \
|
||||||
|
GOSUMDB=sum.golang.google.cn
|
||||||
|
|
||||||
|
WORKDIR /src/ai-chat-backend
|
||||||
|
|
||||||
|
# 先复制依赖描述文件,最大化利用缓存
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||||
|
--mount=type=cache,target=/root/.cache/go-build \
|
||||||
|
go mod download -x
|
||||||
|
|
||||||
|
# 再复制源码
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||||
|
--mount=type=cache,target=/root/.cache/go-build \
|
||||||
|
go build -trimpath -ldflags="-s -w" -o /out/ai-chat-backend ./cmd
|
||||||
|
|
||||||
|
# 运行阶段
|
||||||
|
FROM alpine:3.18 AS runtime
|
||||||
|
|
||||||
|
COPY ./curl-amd64 /usr/bin/curl
|
||||||
RUN chmod +x /usr/bin/curl
|
RUN chmod +x /usr/bin/curl
|
||||||
|
|
||||||
LABEL maintainer="nick"
|
LABEL maintainer="nick"
|
||||||
|
|
||||||
WORKDIR /app/
|
WORKDIR /app/
|
||||||
ADD ./dev.config.yaml /app/config.yaml
|
|
||||||
ADD ./www /app/www
|
COPY ./dev.config.yaml /app/config.yaml
|
||||||
COPY --from=stage0 /src/ai-chat-backend/ai-chat-backend ./
|
COPY ./www /app/www
|
||||||
# 指定入口程序
|
COPY --from=builder /out/ai-chat-backend ./ai-chat-backend
|
||||||
|
|
||||||
ENTRYPOINT ["./ai-chat-backend"]
|
ENTRYPOINT ["./ai-chat-backend"]
|
||||||
# 指定容器的启动命令或者入口程序的参数
|
|
||||||
CMD ["--config=config.yaml"]
|
CMD ["--config=config.yaml"]
|
||||||
@@ -1,22 +1,24 @@
|
|||||||
FROM golang:1.25 AS builder
|
FROM golang:1.25 AS builder
|
||||||
|
|
||||||
ENV GOPROXY=https://proxy.golang.com.cn,https://goproxy.cn,direct \
|
ENV CGO_ENABLED=0 \
|
||||||
GOSUMDB=sum.golang.google.cn \
|
|
||||||
CGO_ENABLED=0 \
|
|
||||||
GOOS=linux \
|
GOOS=linux \
|
||||||
GOARCH=amd64
|
GOARCH=amd64 \
|
||||||
|
GOPROXY=https://goproxy.cn|https://proxy.golang.google.cn|direct \
|
||||||
|
GOSUMDB=sum.golang.google.cn
|
||||||
|
|
||||||
WORKDIR /src/ai-chat-service
|
WORKDIR /src/ai-chat-service
|
||||||
|
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
|
|
||||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||||
--mount=type=cache,target=/root/.cache/go-build \
|
--mount=type=cache,target=/root/.cache/go-build \
|
||||||
go mod download
|
go mod download -x
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||||
--mount=type=cache,target=/root/.cache/go-build \
|
--mount=type=cache,target=/root/.cache/go-build \
|
||||||
go build -o /out/ai-chat-service ./chat-server
|
go build -trimpath -ldflags="-s -w" -o /out/ai-chat-service ./chat-server
|
||||||
|
|
||||||
FROM alpine:3.18
|
FROM alpine:3.18
|
||||||
|
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ services:
|
|||||||
image: keywords-filter:1.0.0
|
image: keywords-filter:1.0.0
|
||||||
container_name: sensitive-filter
|
container_name: sensitive-filter
|
||||||
volumes:
|
volumes:
|
||||||
- /home/lian/share/aichat/ai-chat-stack/configs/sensitive.yaml:/app/config.yaml:ro
|
- ./configs/sensitive.yaml:/app/config.yaml:ro
|
||||||
- /home/lian/share/aichat/ai-chat-stack/configs/sensitive-dict.txt:/app/dict.txt:ro
|
- ./configs/sensitive-dict.txt:/app/dict.txt:ro
|
||||||
command:
|
command:
|
||||||
- --config=/app/config.yaml
|
- --config=/app/config.yaml
|
||||||
- --dict=/app/dict.txt
|
- --dict=/app/dict.txt
|
||||||
@@ -60,8 +60,8 @@ services:
|
|||||||
image: keywords-filter:1.0.0
|
image: keywords-filter:1.0.0
|
||||||
container_name: keywords-filter
|
container_name: keywords-filter
|
||||||
volumes:
|
volumes:
|
||||||
- /home/lian/share/aichat/ai-chat-stack/configs/keywords.yaml:/app/config.yaml:ro
|
- ./configs/keywords.yaml:/app/config.yaml:ro
|
||||||
- /home/lian/share/aichat/ai-chat-stack/configs/keywords-dict.txt:/app/dict.txt:ro
|
- ./configs/keywords-dict.txt:/app/dict.txt:ro
|
||||||
command:
|
command:
|
||||||
- --config=/app/config.yaml
|
- --config=/app/config.yaml
|
||||||
- --dict=/app/dict.txt
|
- --dict=/app/dict.txt
|
||||||
@@ -77,7 +77,7 @@ services:
|
|||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
volumes:
|
volumes:
|
||||||
- /home/lian/share/aichat/ai-chat-stack/configs/ai-chat-service.yaml:/app/config.yaml:ro
|
- ./configs/ai-chat-service.yaml:/app/config.yaml:ro
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
- "host.docker.internal:host-gateway"
|
- "host.docker.internal:host-gateway"
|
||||||
ports:
|
ports:
|
||||||
@@ -103,7 +103,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "7080:7080"
|
- "7080:7080"
|
||||||
volumes:
|
volumes:
|
||||||
- /home/lian/share/aichat/ai-chat-stack/configs/ai-chat-backend.yaml:/app/config.yaml:ro
|
- ./configs/ai-chat-backend.yaml:/app/config.yaml:ro
|
||||||
depends_on:
|
depends_on:
|
||||||
- ai-chat-service
|
- ai-chat-service
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
*/node_modules
|
*/node_modules
|
||||||
node_modules
|
node_modules
|
||||||
Dockerfile
|
Dockerfile
|
||||||
.*
|
*.pyc
|
||||||
|
*.pyo
|
||||||
|
*.log
|
||||||
*/.*
|
*/.*
|
||||||
!.env
|
!.env
|
||||||
!.env.production
|
!.env.production
|
||||||
|
|||||||
@@ -1,15 +1,23 @@
|
|||||||
|
# syntax=docker/dockerfile:1.7
|
||||||
|
|
||||||
FROM quay.io/0voice/node:lts-alpine AS frontend
|
FROM quay.io/0voice/node:lts-alpine AS frontend
|
||||||
RUN npm install pnpm -g
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN npm install -g pnpm@8
|
||||||
|
|
||||||
COPY package.json pnpm-lock.yaml .npmrc ./
|
COPY package.json pnpm-lock.yaml .npmrc ./
|
||||||
RUN pnpm install --frozen-lockfile
|
|
||||||
|
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
|
||||||
|
pnpm install --frozen-lockfile
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN pnpm run build-only
|
RUN pnpm run build-only
|
||||||
|
|
||||||
FROM quay.io/0voice/nginx:1.25.4 AS web
|
FROM quay.io/0voice/nginx:1.25.4 AS web
|
||||||
|
|
||||||
COPY ./docker/nginx/default.conf /etc/nginx/conf.d/default.conf
|
COPY ./docker/nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||||
COPY --from=frontend /app/dist/ /usr/share/nginx/html/
|
COPY --from=frontend /app/dist/ /usr/share/nginx/html/
|
||||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
@@ -1,15 +1,38 @@
|
|||||||
# 编译阶段
|
# syntax=docker/dockerfile:1.7
|
||||||
FROM quay.io/0voice/golang:1.20 as stage0
|
|
||||||
RUN go env -w GOPROXY=https://proxy.golang.com.cn,https://goproxy.cn,direct
|
|
||||||
ADD ./ /src/keywords-filter
|
|
||||||
WORKDIR /src/keywords-filter
|
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o keywords-filter ./filter-server
|
|
||||||
|
|
||||||
FROM quay.io/0voice/alpine:3.18 as stage1
|
# 编译阶段
|
||||||
ADD ./grpc_health_probe-linux-amd64 /usr/bin/grpc_health_probe
|
FROM quay.io/0voice/golang:1.20 AS builder
|
||||||
|
|
||||||
|
ENV CGO_ENABLED=0 \
|
||||||
|
GOOS=linux \
|
||||||
|
GOARCH=amd64 \
|
||||||
|
GOPROXY=https://goproxy.cn|https://proxy.golang.google.cn|direct \
|
||||||
|
GOSUMDB=sum.golang.google.cn
|
||||||
|
|
||||||
|
WORKDIR /src/keywords-filter
|
||||||
|
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||||
|
--mount=type=cache,target=/root/.cache/go-build \
|
||||||
|
go mod download -x
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||||
|
--mount=type=cache,target=/root/.cache/go-build \
|
||||||
|
go build -trimpath -ldflags="-s -w" -o /out/keywords-filter ./filter-server
|
||||||
|
|
||||||
|
# 运行阶段
|
||||||
|
FROM quay.io/0voice/alpine:3.18 AS runtime
|
||||||
|
|
||||||
|
COPY ./grpc_health_probe-linux-amd64 /usr/bin/grpc_health_probe
|
||||||
RUN chmod +x /usr/bin/grpc_health_probe
|
RUN chmod +x /usr/bin/grpc_health_probe
|
||||||
MAINTAINER nick
|
|
||||||
|
LABEL maintainer="nick"
|
||||||
|
|
||||||
WORKDIR /app/
|
WORKDIR /app/
|
||||||
COPY --from=stage0 /src/keywords-filter/keywords-filter ./
|
|
||||||
# 指定入口程序
|
COPY --from=builder /out/keywords-filter ./keywords-filter
|
||||||
|
|
||||||
ENTRYPOINT ["./keywords-filter"]
|
ENTRYPOINT ["./keywords-filter"]
|
||||||
@@ -1,11 +1,19 @@
|
|||||||
|
# syntax=docker/dockerfile:1.7
|
||||||
|
|
||||||
FROM quay.io/0voice/python:3.10-alpine
|
FROM quay.io/0voice/python:3.10-alpine
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ENV PORT 3002
|
|
||||||
|
|
||||||
ADD ./tokenizer.py /app
|
ENV PORT=3002 \
|
||||||
ADD ./requirements.txt /app
|
PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple \
|
||||||
|
PIP_TRUSTED_HOST=pypi.tuna.tsinghua.edu.cn
|
||||||
|
|
||||||
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn --upgrade pip
|
COPY requirements.txt ./
|
||||||
RUN pip install --root-user-action=ignore -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn -r requirements.txt
|
|
||||||
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||||
|
python -m pip install --upgrade pip && \
|
||||||
|
python -m pip install --root-user-action=ignore -r requirements.txt
|
||||||
|
|
||||||
|
COPY tokenizer.py ./
|
||||||
|
|
||||||
CMD ["sh", "-c", "nuxt --port ${PORT} --module tokenizer.py --workers 2"]
|
CMD ["sh", "-c", "nuxt --port ${PORT} --module tokenizer.py --workers 2"]
|
||||||
Reference in New Issue
Block a user