chore: merge docker build (#2317)
* chore: merge docker build * chore: build image * chore: build image * chore: job name
This commit is contained in:
parent
45bc0b83ba
commit
e5612f87f8
@ -1,26 +1,25 @@
|
|||||||
name: Aliyun Container Registry
|
name: Build Docker Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- 'main'
|
- 'main'
|
||||||
- 'develop'
|
|
||||||
paths:
|
paths:
|
||||||
- 'packages/**'
|
- 'packages/**'
|
||||||
- 'docker/nocobase/**'
|
- 'docker/nocobase/**'
|
||||||
- 'Dockerfile.acr'
|
- 'Dockerfile'
|
||||||
- '.github/workflows/aliyun-container-registry.yml'
|
- '.github/workflows/build-docker-image.yml'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- '**'
|
- '**'
|
||||||
paths:
|
paths:
|
||||||
- 'packages/**'
|
- 'packages/**'
|
||||||
- 'docker/nocobase/**'
|
- 'docker/nocobase/**'
|
||||||
- 'Dockerfile.acr'
|
- 'Dockerfile'
|
||||||
- '.github/workflows/aliyun-container-registry.yml'
|
- '.github/workflows/build-docker-image.yml'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
push-acr:
|
build-and-push:
|
||||||
if: github.event.pull_request.head.repo.fork != true
|
if: github.event.pull_request.head.repo.fork != true
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
@ -51,22 +50,41 @@ jobs:
|
|||||||
type=ref,event=pr
|
type=ref,event=pr
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
- name: Login to Docker Hub
|
|
||||||
|
- name: Login to Aliyun Container Registry
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
registry: ${{ secrets.ALI_DOCKER_REGISTRY }}
|
registry: ${{ secrets.ALI_DOCKER_REGISTRY }}
|
||||||
username: ${{ secrets.ALI_DOCKER_USERNAME }}
|
username: ${{ secrets.ALI_DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.ALI_DOCKER_PASSWORD }}
|
password: ${{ secrets.ALI_DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set tags
|
||||||
|
id: set-tags
|
||||||
|
run: |
|
||||||
|
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
|
||||||
|
echo "::set-output name=tags::${{ steps.meta.outputs.tags }},${{ secrets.ALI_DOCKER_REGISTRY }}/${{ steps.meta.outputs.tags }}"
|
||||||
|
else
|
||||||
|
echo "::set-output name=tags::${{ secrets.ALI_DOCKER_REGISTRY }}/${{ steps.meta.outputs.tags }}"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v3
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: Dockerfile.acr
|
file: Dockerfile
|
||||||
build-args: |
|
build-args: |
|
||||||
VERDACCIO_URL=http://localhost:4873/
|
VERDACCIO_URL=http://localhost:4873/
|
||||||
COMMIT_HASH=${GITHUB_SHA}
|
COMMIT_HASH=${GITHUB_SHA}
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ secrets.ALI_DOCKER_REGISTRY }}/${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.set-tags.outputs.tags }}
|
||||||
|
|
||||||
- name: Deploy NocoBase
|
- name: Deploy NocoBase
|
||||||
env:
|
env:
|
||||||
IMAGE_TAG: ${{ steps.meta.outputs.tags }}
|
IMAGE_TAG: ${{ steps.meta.outputs.tags }}
|
61
.github/workflows/docker-hub.yml
vendored
61
.github/workflows/docker-hub.yml
vendored
@ -1,61 +0,0 @@
|
|||||||
name: Docker Hub
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'main'
|
|
||||||
paths:
|
|
||||||
- 'packages/**'
|
|
||||||
- 'docker/nocobase/**'
|
|
||||||
- 'Dockerfile'
|
|
||||||
- '.github/workflows/docker-hub.yml'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
push-docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
services:
|
|
||||||
verdaccio:
|
|
||||||
image: verdaccio/verdaccio
|
|
||||||
ports:
|
|
||||||
- 4873:4873
|
|
||||||
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
|
|
||||||
with:
|
|
||||||
driver-opts: network=host
|
|
||||||
-
|
|
||||||
name: Docker meta
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v4
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
nocobase/nocobase
|
|
||||||
tags: |
|
|
||||||
type=ref,event=branch
|
|
||||||
type=ref,event=pr
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
|
||||||
-
|
|
||||||
name: Login to Docker Hub
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: Dockerfile
|
|
||||||
build-args: |
|
|
||||||
VERDACCIO_URL=http://localhost:4873/
|
|
||||||
# platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
13
Dockerfile
13
Dockerfile
@ -1,6 +1,8 @@
|
|||||||
FROM node:18 as builder
|
FROM node:16 as builder
|
||||||
ARG VERDACCIO_URL=http://host.docker.internal:10104/
|
ARG VERDACCIO_URL=http://host.docker.internal:10104/
|
||||||
ARG COMIT_HASH
|
ARG COMMIT_HASH
|
||||||
|
ARG APPEND_PRESET_LOCAL_PLUGINS
|
||||||
|
ARG BEFORE_PACK_NOCOBASE="ls -l"
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y jq
|
RUN apt-get update && apt-get install -y jq
|
||||||
WORKDIR /tmp
|
WORKDIR /tmp
|
||||||
@ -23,10 +25,13 @@ RUN yarn config set registry $VERDACCIO_URL
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN cd /app \
|
RUN cd /app \
|
||||||
&& yarn config set network-timeout 600000 -g \
|
&& yarn config set network-timeout 600000 -g \
|
||||||
&& yarn create nocobase-app my-nocobase-app -a -e APP_ENV=production \
|
&& yarn create nocobase-app my-nocobase-app -a -e APP_ENV=production -e APPEND_PRESET_LOCAL_PLUGINS=$APPEND_PRESET_LOCAL_PLUGINS \
|
||||||
&& cd /app/my-nocobase-app \
|
&& cd /app/my-nocobase-app \
|
||||||
&& yarn install --production
|
&& yarn install --production
|
||||||
|
|
||||||
|
WORKDIR /app/my-nocobase-app
|
||||||
|
RUN $BEFORE_PACK_NOCOBASE
|
||||||
|
|
||||||
RUN cd /app \
|
RUN cd /app \
|
||||||
&& rm -rf my-nocobase-app/packages/app/client/src/.umi \
|
&& rm -rf my-nocobase-app/packages/app/client/src/.umi \
|
||||||
&& rm -rf nocobase.tar.gz \
|
&& rm -rf nocobase.tar.gz \
|
||||||
@ -50,7 +55,7 @@ COPY --from=builder /app/nocobase.tar.gz /app/nocobase.tar.gz
|
|||||||
|
|
||||||
WORKDIR /app/nocobase
|
WORKDIR /app/nocobase
|
||||||
|
|
||||||
RUN mkdir -p /app/nocobase/storage/uploads/ && echo "$COMIT_HASH" >> /app/nocobase/storage/uploads/COMIT_HASH
|
RUN mkdir -p /app/nocobase/storage/uploads/ && echo "$COMMIT_HASH" >> /app/nocobase/storage/uploads/COMMIT_HASH
|
||||||
|
|
||||||
COPY ./docker/nocobase/docker-entrypoint.sh /app/
|
COPY ./docker/nocobase/docker-entrypoint.sh /app/
|
||||||
|
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
FROM node:16 as builder
|
|
||||||
ARG VERDACCIO_URL=http://host.docker.internal:10104/
|
|
||||||
ARG COMMIT_HASH
|
|
||||||
ARG APPEND_PRESET_LOCAL_PLUGINS
|
|
||||||
ARG BEFORE_PACK_NOCOBASE="ls -l"
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y jq
|
|
||||||
WORKDIR /tmp
|
|
||||||
COPY . /tmp
|
|
||||||
RUN npx npm-cli-adduser --username test --password test -e test@nocobase.com -r $VERDACCIO_URL
|
|
||||||
RUN cd /tmp && \
|
|
||||||
NEWVERSION="$(cat lerna.json | jq '.version' | tr -d '"').$(date +'%Y%m%d%H%M%S')" \
|
|
||||||
&& tmp=$(mktemp) \
|
|
||||||
&& jq ".version = \"${NEWVERSION}\"" lerna.json > "$tmp" && mv "$tmp" lerna.json
|
|
||||||
RUN yarn install && yarn build
|
|
||||||
|
|
||||||
RUN git checkout -b release \
|
|
||||||
&& yarn version:alpha -y \
|
|
||||||
&& git config user.email "test@mail.com" \
|
|
||||||
&& git config user.name "test" && git add . \
|
|
||||||
&& git commit -m "chore(versions): test publish packages xxx" \
|
|
||||||
&& yarn release:force --registry $VERDACCIO_URL
|
|
||||||
|
|
||||||
RUN yarn config set registry $VERDACCIO_URL
|
|
||||||
WORKDIR /app
|
|
||||||
RUN cd /app \
|
|
||||||
&& yarn config set network-timeout 600000 -g \
|
|
||||||
&& yarn create nocobase-app my-nocobase-app -a -e APP_ENV=production -e APPEND_PRESET_LOCAL_PLUGINS=$APPEND_PRESET_LOCAL_PLUGINS \
|
|
||||||
&& cd /app/my-nocobase-app \
|
|
||||||
&& yarn install --production
|
|
||||||
|
|
||||||
WORKDIR /app/my-nocobase-app
|
|
||||||
RUN $BEFORE_PACK_NOCOBASE
|
|
||||||
|
|
||||||
RUN cd /app \
|
|
||||||
&& rm -rf my-nocobase-app/packages/app/client/src/.umi \
|
|
||||||
&& rm -rf nocobase.tar.gz \
|
|
||||||
&& rm -rf ./my-nocobase-app/node_modules/@antv \
|
|
||||||
&& rm -rf ./my-nocobase-app/node_modules/antd/dist \
|
|
||||||
&& rm -rf ./my-nocobase-app/node_modules/antd/es \
|
|
||||||
&& rm -rf ./my-nocobase-app/node_modules/antd/node_modules \
|
|
||||||
&& rm -rf ./my-nocobase-app/node_modules/@ant-design \
|
|
||||||
&& rm -rf ./my-nocobase-app/node_modules/china-division/dist/villages.json \
|
|
||||||
&& find ./my-nocobase-app/node_modules/china-division/dist -name '*.csv' -delete \
|
|
||||||
&& find ./my-nocobase-app/node_modules/china-division/dist -name '*.sqlite' -delete \
|
|
||||||
&& tar -zcf ./nocobase.tar.gz -C /app/my-nocobase-app .
|
|
||||||
|
|
||||||
|
|
||||||
FROM node:16.20-bullseye-slim
|
|
||||||
RUN apt-get update && apt-get install -y nginx
|
|
||||||
|
|
||||||
RUN rm -rf /etc/nginx/sites-enabled/default
|
|
||||||
COPY ./docker/nocobase/nocobase.conf /etc/nginx/sites-enabled/nocobase.conf
|
|
||||||
COPY --from=builder /app/nocobase.tar.gz /app/nocobase.tar.gz
|
|
||||||
|
|
||||||
WORKDIR /app/nocobase
|
|
||||||
|
|
||||||
RUN mkdir -p /app/nocobase/storage/uploads/ && echo "$COMMIT_HASH" >> /app/nocobase/storage/uploads/COMMIT_HASH
|
|
||||||
|
|
||||||
COPY ./docker/nocobase/docker-entrypoint.sh /app/
|
|
||||||
|
|
||||||
CMD ["/app/docker-entrypoint.sh"]
|
|
||||||
|
|
@ -20406,6 +20406,11 @@ prettier@^3.0.0:
|
|||||||
version "3.0.0"
|
version "3.0.0"
|
||||||
resolved "https://registry.npmjs.org/prettier/-/prettier-3.0.0.tgz#e7b19f691245a21d618c68bc54dc06122f6105ae"
|
resolved "https://registry.npmjs.org/prettier/-/prettier-3.0.0.tgz#e7b19f691245a21d618c68bc54dc06122f6105ae"
|
||||||
|
|
||||||
|
prettier@^3.0.0:
|
||||||
|
version "3.0.0"
|
||||||
|
resolved "https://registry.npmjs.org/prettier/-/prettier-3.0.0.tgz#e7b19f691245a21d618c68bc54dc06122f6105ae"
|
||||||
|
integrity sha512-zBf5eHpwHOGPC47h0zrPyNn+eAEIdEzfywMoYn2XPi0P44Zp0tSq64rq0xAREh4auw2cJZHo9QUob+NqCQky4g==
|
||||||
|
|
||||||
pretty-error@^4.0.0:
|
pretty-error@^4.0.0:
|
||||||
version "4.0.0"
|
version "4.0.0"
|
||||||
resolved "https://registry.npmmirror.com/pretty-error/-/pretty-error-4.0.0.tgz#90a703f46dd7234adb46d0f84823e9d1cb8f10d6"
|
resolved "https://registry.npmmirror.com/pretty-error/-/pretty-error-4.0.0.tgz#90a703f46dd7234adb46d0f84823e9d1cb8f10d6"
|
||||||
|
Loading…
Reference in New Issue
Block a user