diff --git a/.dockerignore b/.dockerignore index cdedf76ac2bee..ba158a6ae6799 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,7 @@ -# local build artifacts that must not be included -/composer.lock -/node_modules /vendor +.* +DEVELOPERS.md +Gruntfile.js +package-lock.json +package.json +phpunit.xml.dist diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cf92db258c766..33f8ae79b4a7b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,25 +14,61 @@ jobs: with: submodules: recursive - - name: Setup PHP with composer - uses: shivammathur/setup-php@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Log into registry Aliyun Container Registry + uses: docker/login-action@v3 + with: + registry: registry.cn-shanghai.aliyuncs.com + username: ${{ secrets.ALI_CR_USERNAME }} + password: ${{ secrets.ALI_CR_PASSWORD }} + + - name: Extract mw Docker Metadata + id: mw_meta + uses: docker/metadata-action@v5 with: - php-version: "8.1" - - - name: Install dependencies - run: composer update --no-dev - - - name: Pack - run: | - cd .. - tar --exclude-from=./mw/.github/workflows/exclude -czvf dist.tgz mw - - name: Get current time - id: date - run: echo "now=$(TZ='Asia/Shanghai' date +'%Y-%m-%d-%H-%M-%S')" >> $GITHUB_OUTPUT - - name: Create release - uses: softprops/action-gh-release@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + images: | + registry.cn-shanghai.aliyuncs.com/prts/mw + ghcr.io/mooncellwiki/mw + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: .github/workflows/mw.Dockerfile + push: true + tags: ${{ steps.mw_meta.outputs.tags }} + labels: ${{ steps.mw_meta.outputs.labels }} + + - name: Extract nginx Docker Metadata + id: ng_meta + uses: docker/metadata-action@v5 + with: + images: | + registry.cn-shanghai.aliyuncs.com/prts/ng + ghcr.io/mooncellwiki/ng + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha + + - name: Build and push Docker image + uses: docker/build-push-action@v5 with: - files: ../dist.tgz - tag_name: ${{ steps.date.outputs.now }} + context: . + file: .github/workflows/nginx.Dockerfile + push: true + tags: ${{ steps.ng_meta.outputs.tags }} + labels: ${{ steps.ng_meta.outputs.labels }} diff --git a/.github/workflows/exclude b/.github/workflows/exclude deleted file mode 100644 index 821d7f6859530..0000000000000 --- a/.github/workflows/exclude +++ /dev/null @@ -1,6 +0,0 @@ -.* -DEVELOPERS.md -Gruntfile.js -package-lock.json -package.json -phpunit.xml.dist diff --git a/.github/workflows/mw.Dockerfile b/.github/workflows/mw.Dockerfile new file mode 100644 index 0000000000000..86d57efb51759 --- /dev/null +++ b/.github/workflows/mw.Dockerfile @@ -0,0 +1,9 @@ +FROM ghcr.io/mooncellwiki/php:latest + +VOLUME [ "/var/www/html/etc" ] + +COPY . /var/www/html/ + +WORKDIR /var/www/html/ + +RUN composer install --no-dev diff --git a/.github/workflows/nginx.Dockerfile b/.github/workflows/nginx.Dockerfile new file mode 100644 index 0000000000000..8eadb39664645 --- /dev/null +++ b/.github/workflows/nginx.Dockerfile @@ -0,0 +1,3 @@ +FROM ghcr.io/mooncellwiki/mw:latest as builder +FROM nginx:1.25 +COPY --from=builder /var/www/html/ /var/www/html/