docker fix
This commit is contained in:
@@ -1,19 +1,41 @@
|
||||
# 编译阶段
|
||||
FROM golang:1.24 AS stage0
|
||||
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 golang:1.24 AS builder
|
||||
|
||||
FROM alpine:3.18 AS stage1
|
||||
ADD ./curl-amd64 /usr/bin/curl
|
||||
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/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
|
||||
|
||||
LABEL maintainer="nick"
|
||||
|
||||
WORKDIR /app/
|
||||
ADD ./dev.config.yaml /app/config.yaml
|
||||
ADD ./www /app/www
|
||||
COPY --from=stage0 /src/ai-chat-backend/ai-chat-backend ./
|
||||
# 指定入口程序
|
||||
|
||||
COPY ./dev.config.yaml /app/config.yaml
|
||||
COPY ./www /app/www
|
||||
COPY --from=builder /out/ai-chat-backend ./ai-chat-backend
|
||||
|
||||
ENTRYPOINT ["./ai-chat-backend"]
|
||||
# 指定容器的启动命令或者入口程序的参数
|
||||
CMD ["--config=config.yaml"]
|
||||
@@ -1,22 +1,24 @@
|
||||
FROM golang:1.25 AS builder
|
||||
|
||||
ENV GOPROXY=https://proxy.golang.com.cn,https://goproxy.cn,direct \
|
||||
GOSUMDB=sum.golang.google.cn \
|
||||
CGO_ENABLED=0 \
|
||||
ENV CGO_ENABLED=0 \
|
||||
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
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
go mod download
|
||||
go mod download -x
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--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
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ services:
|
||||
image: keywords-filter:1.0.0
|
||||
container_name: sensitive-filter
|
||||
volumes:
|
||||
- /home/lian/share/aichat/ai-chat-stack/configs/sensitive.yaml:/app/config.yaml:ro
|
||||
- /home/lian/share/aichat/ai-chat-stack/configs/sensitive-dict.txt:/app/dict.txt:ro
|
||||
- ./configs/sensitive.yaml:/app/config.yaml:ro
|
||||
- ./configs/sensitive-dict.txt:/app/dict.txt:ro
|
||||
command:
|
||||
- --config=/app/config.yaml
|
||||
- --dict=/app/dict.txt
|
||||
@@ -60,8 +60,8 @@ services:
|
||||
image: keywords-filter:1.0.0
|
||||
container_name: keywords-filter
|
||||
volumes:
|
||||
- /home/lian/share/aichat/ai-chat-stack/configs/keywords.yaml:/app/config.yaml:ro
|
||||
- /home/lian/share/aichat/ai-chat-stack/configs/keywords-dict.txt:/app/dict.txt:ro
|
||||
- ./configs/keywords.yaml:/app/config.yaml:ro
|
||||
- ./configs/keywords-dict.txt:/app/dict.txt:ro
|
||||
command:
|
||||
- --config=/app/config.yaml
|
||||
- --dict=/app/dict.txt
|
||||
@@ -77,7 +77,7 @@ services:
|
||||
env_file:
|
||||
- .env
|
||||
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:
|
||||
- "host.docker.internal:host-gateway"
|
||||
ports:
|
||||
@@ -103,7 +103,7 @@ services:
|
||||
ports:
|
||||
- "7080:7080"
|
||||
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:
|
||||
- ai-chat-service
|
||||
restart: unless-stopped
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
*/node_modules
|
||||
node_modules
|
||||
Dockerfile
|
||||
.*
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.log
|
||||
*/.*
|
||||
!.env
|
||||
!.env.production
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
# syntax=docker/dockerfile:1.7
|
||||
|
||||
FROM quay.io/0voice/node:lts-alpine AS frontend
|
||||
RUN npm install pnpm -g
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN npm install -g pnpm@8
|
||||
|
||||
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 . .
|
||||
|
||||
RUN pnpm run build-only
|
||||
|
||||
FROM quay.io/0voice/nginx:1.25.4 AS web
|
||||
|
||||
COPY ./docker/nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=frontend /app/dist/ /usr/share/nginx/html/
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
@@ -1,15 +1,38 @@
|
||||
# 编译阶段
|
||||
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
|
||||
# syntax=docker/dockerfile:1.7
|
||||
|
||||
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
|
||||
MAINTAINER nick
|
||||
|
||||
LABEL maintainer="nick"
|
||||
|
||||
WORKDIR /app/
|
||||
COPY --from=stage0 /src/keywords-filter/keywords-filter ./
|
||||
# 指定入口程序
|
||||
|
||||
COPY --from=builder /out/keywords-filter ./keywords-filter
|
||||
|
||||
ENTRYPOINT ["./keywords-filter"]
|
||||
@@ -1,11 +1,19 @@
|
||||
# syntax=docker/dockerfile:1.7
|
||||
|
||||
FROM quay.io/0voice/python:3.10-alpine
|
||||
|
||||
WORKDIR /app
|
||||
ENV PORT 3002
|
||||
|
||||
ADD ./tokenizer.py /app
|
||||
ADD ./requirements.txt /app
|
||||
ENV PORT=3002 \
|
||||
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
|
||||
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
|
||||
COPY requirements.txt ./
|
||||
|
||||
CMD ["sh","-c","nuxt --port ${PORT} --module tokenizer.py --workers 2"]
|
||||
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"]
|
||||
Reference in New Issue
Block a user