Skip to content

Commit

Permalink
build: docker
Browse files Browse the repository at this point in the history
  • Loading branch information
daflyinbed committed Apr 29, 2024
1 parent c29ac74 commit f2cc366
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 29 deletions.
9 changes: 6 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -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
76 changes: 56 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
6 changes: 0 additions & 6 deletions .github/workflows/exclude

This file was deleted.

9 changes: 9 additions & 0 deletions .github/workflows/mw.Dockerfile
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .github/workflows/nginx.Dockerfile
Original file line number Diff line number Diff line change
@@ -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/

0 comments on commit f2cc366

Please sign in to comment.