Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

works: auth connect #1

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
48ab2bc
works: auth connect
whatwewant Oct 20, 2023
4986515
chore: merge upstream
whatwewant Oct 20, 2023
6140f34
ci: update build image
whatwewant Oct 20, 2023
7d4c199
chore(release): bumped version to v4.5-1.2.0
whatwewant Oct 20, 2023
c2d2cdd
chore(release): bumped version to v4.5-1.2.1
whatwewant Oct 20, 2023
69eb051
chore(release): bumped version to v4.5-1.2.2
whatwewant Oct 20, 2023
5f14187
ci: fix image
whatwewant Oct 20, 2023
ea2bf2f
chore(release): bumped version to v4.5-1.2.3
whatwewant Oct 20, 2023
a7f9671
ci: fix image
whatwewant Oct 20, 2023
6f0e512
chore(release): bumped version to v4.5-1.2.4
whatwewant Oct 20, 2023
b1770bb
ci: fix
whatwewant Oct 20, 2023
94d1bca
chore(release): bumped version to v4.5-1.2.5
whatwewant Oct 20, 2023
51b71b3
chore(release): bumped version to v4.5-1.2.6
whatwewant Oct 20, 2023
89c5d36
chore(release): bumped version to v4.5-1.2.7
whatwewant Oct 20, 2023
62ae551
chore(release): bumped version to v4.5-1.2.8
whatwewant Oct 20, 2023
9b64002
chore(release): bumped version to v4.5-1.2.9
whatwewant Oct 20, 2023
e19a115
chore(release): bumped version to v4.5-1.2.10
whatwewant Oct 20, 2023
9a501d3
chore(release): bumped version to v4.5-1.2.11
whatwewant Oct 20, 2023
adb31fe
ci: fix
whatwewant Oct 20, 2023
53c62dc
ci: fix
whatwewant Oct 20, 2023
10436a8
chore(release): bumped version to v4.5-1.2.12
whatwewant Oct 20, 2023
5202a6d
chore(release): bumped version to v4.5-1.2.13
whatwewant Oct 20, 2023
cd28e1b
chore(release): bumped version to v4.5-1.2.14
whatwewant Oct 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
- 'docSite/**'
branches:
- 'main'
tags:
- 'v*.*.*'
# tags:
# - 'v*.*.*'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docs-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
- 'docSite/**'
branches:
- 'main'
tags:
- 'v*.*.*'
# tags:
# - 'v*.*.*'
jobs:
build-fastgpt-docs-images:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -95,4 +95,4 @@ jobs:
env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
with:
args: rollout restart deployment fastgpt-docs
args: rollout restart deployment fastgpt-docs
225 changes: 126 additions & 99 deletions .github/workflows/fastgpt-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ name: Build FastGPT images and copy image to docker hub
on:
workflow_dispatch:
push:
paths:
- 'projects/app/**'
- 'packages/**'
branches:
- 'main'
# paths:
# - 'projects/app/**'
# - 'packages/**'
# branches:
# - 'main'
tags:
- 'v*.*.*'
- 'v*'
jobs:
build-fastgpt-images:
runs-on: ubuntu-20.04
Expand All @@ -17,99 +17,126 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Install Dependencies
run: |
sudo apt update && sudo apt install -y nodejs npm
- name: Set up QEMU (optional)
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: network=host
- name: Cache Docker layers
uses: actions/cache@v2

- name: Docker Meta
id: meta
uses: zmicro-design/action-docker-image-meta@v1
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_PAT }}
- name: Set DOCKER_REPO_TAGGED based on branch or tag
run: |
if [[ "${{ github.ref_name }}" == "main" ]]; then
echo "DOCKER_REPO_TAGGED=ghcr.io/${{ github.repository_owner }}/fastgpt:latest" >> $GITHUB_ENV
else
echo "DOCKER_REPO_TAGGED=ghcr.io/${{ github.repository_owner }}/fastgpt:${{ github.ref_name }}" >> $GITHUB_ENV
fi
- name: Build and publish image for main branch or tag push event
env:
DOCKER_REPO_TAGGED: ${{ env.DOCKER_REPO_TAGGED }}
username: ${{ secrets.DOCKERHUB_USERNAME }}

- name: Show Docker Tags
run: |
docker buildx build \
--build-arg name=app \
--platform linux/amd64,linux/arm64 \
--label "org.opencontainers.image.source= https://github.com/ ${{ github.repository_owner }}/FastGPT" \
--label "org.opencontainers.image.description=fastgpt image" \
--label "org.opencontainers.image.licenses=Apache" \
--push \
--cache-from=type=local,src=/tmp/.buildx-cache \
--cache-to=type=local,dest=/tmp/.buildx-cache \
-t ${DOCKER_REPO_TAGGED} \
-f Dockerfile \
.
push-to-docker-hub:
needs: build-fastgpt-images
runs-on: ubuntu-20.04
if: github.repository == 'labring/FastGPT'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
echo "Docker Tags: ${{ steps.meta.outputs.tags }}"

- name: Build and push
uses: zmicro-design/action-docker-build@v1
with:
username: ${{ secrets.DOCKER_HUB_NAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Set DOCKER_REPO_TAGGED based on branch or tag
run: |
if [[ "${{ github.ref_name }}" == "main" ]]; then
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
else
echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
fi
- name: Pull image from GitHub Container Registry
run: docker pull ghcr.io/${{ github.repository_owner }}/fastgpt:${{env.IMAGE_TAG}}
- name: Tag image with Docker Hub repository name and version tag
run: docker tag ghcr.io/${{ github.repository_owner }}/fastgpt:${{env.IMAGE_TAG}} ${{ secrets.DOCKER_IMAGE_NAME }}:${{env.IMAGE_TAG}}
- name: Push image to Docker Hub
run: docker push ${{ secrets.DOCKER_IMAGE_NAME }}:${{env.IMAGE_TAG}}
push-to-ali-hub:
needs: build-fastgpt-images
if: github.repository == 'labring/FastGPT'
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to Ali Hub
uses: docker/login-action@v2
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.ALI_HUB_USERNAME }}
password: ${{ secrets.ALI_HUB_PASSWORD }}
- name: Set DOCKER_REPO_TAGGED based on branch or tag
run: |
if [[ "${{ github.ref_name }}" == "main" ]]; then
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
else
echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
fi
- name: Pull image from GitHub Container Registry
run: docker pull ghcr.io/${{ github.repository_owner }}/fastgpt:${{env.IMAGE_TAG}}
- name: Tag image with Docker Hub repository name and version tag
run: docker tag ghcr.io/${{ github.repository_owner }}/fastgpt:${{env.IMAGE_TAG}} ${{ secrets.ALI_IMAGE_NAME }}:${{env.IMAGE_TAG}}
- name: Push image to Docker Hub
run: docker push ${{ secrets.ALI_IMAGE_NAME }}:${{env.IMAGE_TAG}}
build-args: |
name=app
context: .
push: ${{ github.event_name != 'pull_request' }}
cache-from: type=registry,ref=${{ steps.meta.outputs.name }}:buildcache
cache-to: type=registry,ref=${{ steps.meta.outputs.name }}:buildcache,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
#
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# - name: Install Dependencies
# run: |
# sudo apt update && sudo apt install -y nodejs npm
# - name: Set up QEMU (optional)
# uses: docker/setup-qemu-action@v2
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
# with:
# driver-opts: network=host
# - name: Cache Docker layers
# uses: actions/cache@v2
# with:
# path: /tmp/.buildx-cache
# key: ${{ runner.os }}-buildx-${{ github.sha }}
# restore-keys: |
# ${{ runner.os }}-buildx-
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v2
# with:
# registry: ghcr.io
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Set DOCKER_REPO_TAGGED based on branch or tag
# run: |
# if [[ "${{ github.ref_name }}" == "main" ]]; then
# echo "DOCKER_REPO_TAGGED=ghcr.io/${{ github.repository_owner }}/fastgpt:latest" >> $GITHUB_ENV
# else
# echo "DOCKER_REPO_TAGGED=ghcr.io/${{ github.repository_owner }}/fastgpt:${{ github.ref_name }}" >> $GITHUB_ENV
# fi
# - name: Build and publish image for main branch or tag push event
# env:
# DOCKER_REPO_TAGGED: ${{ env.DOCKER_REPO_TAGGED }}
# run: |
# docker buildx build \
# --build-arg name=app \
# --platform linux/amd64,linux/arm64 \
# --label "org.opencontainers.image.source= https://github.com/ ${{ github.repository_owner }}/FastGPT" \
# --label "org.opencontainers.image.description=fastgpt image" \
# --label "org.opencontainers.image.licenses=Apache" \
# --push \
# --cache-from=type=local,src=/tmp/.buildx-cache \
# --cache-to=type=local,dest=/tmp/.buildx-cache \
# -t ${DOCKER_REPO_TAGGED} \
# -f Dockerfile \
# .
# push-to-docker-hub:
# needs: build-fastgpt-images
# runs-on: ubuntu-20.04
# if: github.repository == 'labring/FastGPT'
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Login to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Set DOCKER_REPO_TAGGED based on branch or tag
# run: |
# if [[ "${{ github.ref_name }}" == "main" ]]; then
# echo "IMAGE_TAG=latest" >> $GITHUB_ENV
# else
# echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
# fi
# - name: Pull image from GitHub Container Registry
# run: docker pull ghcr.io/${{ github.repository_owner }}/fastgpt:${{env.IMAGE_TAG}}
# - name: Tag image with Docker Hub repository name and version tag
# run: docker tag ghcr.io/${{ github.repository_owner }}/fastgpt:${{env.IMAGE_TAG}} ${{ secrets.DOCKER_IMAGE_NAME }}:${{env.IMAGE_TAG}}
# - name: Push image to Docker Hub
# run: docker push ${{ secrets.DOCKER_IMAGE_NAME }}:${{env.IMAGE_TAG}}
# push-to-ali-hub:
# needs: build-fastgpt-images
# if: github.repository == 'labring/FastGPT'
# runs-on: ubuntu-20.04
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Login to Ali Hub
# uses: docker/login-action@v2
# with:
# registry: registry.cn-hangzhou.aliyuncs.com
# username: ${{ secrets.ALI_HUB_USERNAME }}
# password: ${{ secrets.ALI_HUB_PASSWORD }}
# - name: Set DOCKER_REPO_TAGGED based on branch or tag
# run: |
# if [[ "${{ github.ref_name }}" == "main" ]]; then
# echo "IMAGE_TAG=latest" >> $GITHUB_ENV
# else
# echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
# fi
# - name: Pull image from GitHub Container Registry
# run: docker pull ghcr.io/${{ github.repository_owner }}/fastgpt:${{env.IMAGE_TAG}}
# - name: Tag image with Docker Hub repository name and version tag
# run: docker tag ghcr.io/${{ github.repository_owner }}/fastgpt:${{env.IMAGE_TAG}} ${{ secrets.ALI_IMAGE_NAME }}:${{env.IMAGE_TAG}}
# - name: Push image to Docker Hub
# run: docker push ${{ secrets.ALI_IMAGE_NAME }}:${{env.IMAGE_TAG}}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ dist/
**/.hugo_build.lock
docSite/public/
docSite/resources/_gen/
docSite/.vercel
docSite/.vercel

.env
.connect
37 changes: 19 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
# Install dependencies only when needed
FROM node:current-alpine AS deps
FROM whatwewant/builder-node:v20-1 AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat && npm install -g pnpm
RUN apt update -y && apt install -y libpq-dev
RUN npm install -g pnpm
WORKDIR /app

ARG name

# copy packages and one project
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY package.json .
COPY pnpm-lock.yaml .
COPY pnpm-workspace.yaml .
COPY ./packages ./packages
COPY ./projects/$name/package.json ./projects/$name/package.json

RUN \
[ -f pnpm-lock.yaml ] && pnpm install || \
(echo "Lockfile not found." && exit 1)
RUN ls -al && pnpm i

# Rebuild the source code only when needed
FROM node:current-alpine AS builder
FROM whatwewant/builder-node:v20-1 AS builder

WORKDIR /app

ARG name
Expand All @@ -33,36 +35,35 @@ ENV NEXT_TELEMETRY_DISABLED 1
RUN npm install -g pnpm
RUN pnpm --filter=$name run build

FROM node:current-alpine AS runner
FROM whatwewant/node:v20-2 AS runner

WORKDIR /app

ARG name

# create user and use it
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# # create user and use it
# RUN addgroup --system --gid 1001 nodejs
# RUN adduser --system --uid 1001 nextjs

RUN sed -i 's/https/http/' /etc/apk/repositories
RUN apk add curl \
&& apk add ca-certificates \
&& update-ca-certificates
RUN apk add curl && apk add ca-certificates && update-ca-certificates

# copy running files
COPY --from=builder /app/projects/$name/public ./projects/$name/public
COPY --from=builder /app/projects/$name/next.config.js ./projects/$name/next.config.js
COPY --from=builder --chown=nextjs:nodejs /app/projects/$name/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/projects/$name/.next/static ./projects/$name/.next/static
# copy package.json to version file
COPY --from=builder /app/projects/$name/package.json ./package.json
COPY --from=builder /app/projects/$name/package.json ./package.json

COPY ./config/config.json /app/data/config.json

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
ENV PORT=3000

EXPOSE 3000

USER nextjs

ENV serverPath=./projects/$name/server.js

ENTRYPOINT ["sh","-c","node ${serverPath}"]
ENTRYPOINT ["sh","-c","node ${serverPath}"]
Loading