From afb0bbbb0832f3218b84c8d1d5f2b2081080e0ec Mon Sep 17 00:00:00 2001 From: chenos Date: Tue, 20 May 2025 22:44:45 +0800 Subject: [PATCH] chore: build the full docker image (#6898) * chore: build full docker image * fix: dockerfile-cn * chore: update Dockerfile * fix: error * chore: update ci --- .github/workflows/build-docker.yml | 44 ++++++++++++++++ docker/nocobase/Dockerfile-cn | 75 ++++++++++++++++++++++++++++ docker/nocobase/docker-entrypoint.sh | 12 +++++ 3 files changed, 131 insertions(+) create mode 100644 .github/workflows/build-docker.yml create mode 100644 docker/nocobase/Dockerfile-cn diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml new file mode 100644 index 00000000000..8d7fbba2860 --- /dev/null +++ b/.github/workflows/build-docker.yml @@ -0,0 +1,44 @@ +name: Build full docker image + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + workflow_dispatch: + inputs: + tag_name: + description: 'Tag name' + required: true + +jobs: + push-docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to Aliyun Container Registry (Public) + uses: docker/login-action@v2 + with: + registry: ${{ secrets.ALI_DOCKER_PUBLIC_REGISTRY }} + username: ${{ secrets.ALI_DOCKER_USERNAME }} + password: ${{ secrets.ALI_DOCKER_PASSWORD }} + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: ./docker/nocobase + file: ./docker/nocobase/Dockerfile-cn + build-args: | + CNA_VERSION=${{ inputs.tag_name }} + platforms: linux/amd64,linux/arm64 + push: true + tags: nocobase/nocobase:${{ inputs.tag_name }}-full,${{ secrets.ALI_DOCKER_PUBLIC_REGISTRY }}/nocobase/nocobase:${{ inputs.tag_name }}-full diff --git a/docker/nocobase/Dockerfile-cn b/docker/nocobase/Dockerfile-cn new file mode 100644 index 00000000000..86de0882c7f --- /dev/null +++ b/docker/nocobase/Dockerfile-cn @@ -0,0 +1,75 @@ +FROM node:20-bookworm-slim as builder + +ARG CNA_VERSION=latest + +WORKDIR /app + +RUN cd /app \ + && yarn config set network-timeout 600000 -g \ + && npx -y create-nocobase-app@${CNA_VERSION} my-nocobase-app --skip-dev-dependencies -a -e APP_ENV=production \ + && cd /app/my-nocobase-app \ + && yarn install --production \ + && rm -rf yarn.lock \ + && find node_modules -type f -name "yarn.lock" -delete \ + && find node_modules -type f -name "bower.json" -delete \ + && find node_modules -type f -name "composer.json" -delete + +RUN cd /app \ + && rm -rf nocobase.tar.gz \ + && tar -zcf ./nocobase.tar.gz -C /app/my-nocobase-app . + +FROM node:20-bookworm-slim + +RUN tee /etc/apt/sources.list > /dev/null < /etc/apt/sources.list.d/pgdg.list' +RUN wget --quiet -O - http://mirrors.aliyun.com/postgresql/repos/apt/ACCC4CF8.asc | apt-key add - + +RUN apt-get update && apt-get install -y --no-install-recommends \ + nginx \ + libaio1 \ + postgresql-client-16 \ + postgresql-client-17 \ + libfreetype6 \ + fontconfig \ + libgssapi-krb5-2 \ + fonts-liberation \ + fonts-noto-cjk \ + unzip \ + && rm -rf /var/lib/apt/lists/* + +RUN rm -rf /etc/nginx/sites-enabled/default +COPY --from=builder /app/nocobase.tar.gz /app/nocobase.tar.gz + +RUN wget --no-check-certificate -O /opt/libreoffice24.8.zip https://static-docs.nocobase.com/libreoffice24.8.zip +RUN wget --no-check-certificate -O /opt/instantclient_19_25.zip https://download.oracle.com/otn_software/linux/instantclient/1925000/instantclient-basic-linux.x64-19.25.0.0.0dbru.zip +RUN wget --no-check-certificate https://downloads.mysql.com/archives/get/p/23/file/mysql-community-client-core_8.0.39-1debian12_amd64.deb && \ + dpkg -x mysql-community-client-core_8.0.39-1debian12_amd64.deb /tmp/mysql-client && \ + cp /tmp/mysql-client/usr/bin/mysqldump /usr/bin/ && \ + cp /tmp/mysql-client/usr/bin/mysql /usr/bin/ && \ + rm mysql-community-client-core_8.0.39-1debian12_amd64.deb + +WORKDIR /app/nocobase + +COPY docker-entrypoint.sh /app/ +# COPY docker-entrypoint.sh /usr/local/bin/ +# ENTRYPOINT ["docker-entrypoint.sh"] + +EXPOSE 80/tcp + +CMD ["/app/docker-entrypoint.sh"] \ No newline at end of file diff --git a/docker/nocobase/docker-entrypoint.sh b/docker/nocobase/docker-entrypoint.sh index 6793afe27a6..98ab475f2e1 100755 --- a/docker/nocobase/docker-entrypoint.sh +++ b/docker/nocobase/docker-entrypoint.sh @@ -5,6 +5,18 @@ echo "COMMIT_HASH: $(cat /app/commit_hash.txt)" export NOCOBASE_RUNNING_IN_DOCKER=true +if [ -f /opt/libreoffice24.8.zip ] && [ ! -d /opt/libreoffice24.8 ]; then + echo "Unzipping /opt/libreoffice24.8.zip..." + unzip /opt/libreoffice24.8.zip -d /opt/ +fi + +if [ -f /opt/instantclient_19_25.zip ] && [ ! -d /opt/instantclient_19_25 ]; then + echo "Unzipping /opt/instantclient_19_25.zip..." + unzip /opt/instantclient_19_25.zip -d /opt/ + echo "/opt/instantclient_19_25" > /etc/ld.so.conf.d/oracle-instantclient.conf + ldconfig +fi + if [ ! -d "/app/nocobase" ]; then mkdir nocobase fi