Skip to content

Commit

Permalink
feat: Integrate build process into Dockerfile and enable multi-platfo…
Browse files Browse the repository at this point in the history
…rm builds in GitHub Actions
  • Loading branch information
HalcyonAzure committed Oct 27, 2023
2 parents 80ee78b + 8a57929 commit feefbde
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 22 deletions.
30 changes: 11 additions & 19 deletions .github/workflows/update-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Download and Unzip Upstream Source Code
run: |
curl -OL https://github.com/lsky-org/lsky-pro/archive/refs/heads/master.zip
unzip *.zip
mv ./lsky-pro-master/* ./
mv ./lsky-pro-master/.env.example ./
rm -rf master.zip lsky-pro-master
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
php-version: '8.1'

- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"

- name: Install Dependencies
run: composer install
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
Expand All @@ -42,6 +30,10 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
run: |
docker build -t halcyonazure/lsky-pro-docker:latest .
docker push halcyonazure/lsky-pro-docker:latest
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: halcyonazure/lsky-pro-docker:dev
21 changes: 20 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
FROM php:8.1 AS build
WORKDIR /build

# 安装必要的依赖
RUN apt-get update && \
apt-get install -y curl unzip && \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN curl -OL https://github.com/lsky-org/lsky-pro/archive/refs/heads/master.zip \
&& unzip *.zip \
&& mv ./lsky-pro-master/* ./ \
&& mv ./lsky-pro-master/.env.example ./ \
&& rm -rf master.zip lsky-pro-master

RUN php -r "file_exists('.env') || copy('.env.example', '.env');" \
&& composer install

FROM php:8.1-apache

# 如果构建速度慢可以换源
# RUN sed -i -E "s@http://.*.debian.org@http://mirrors.cloud.tencent.com@g" /etc/apt/sources.list
# 安装相关拓展
Expand Down Expand Up @@ -33,7 +52,7 @@ RUN apt-get update && \
chown -R www-data:root /var/www; \
chmod -R g=u /var/www

COPY ./ /var/www/lsky/
COPY --from=build /build /var/www/lsky/
COPY ./000-default.conf.template /etc/apache2/sites-enabled/
COPY ./ports.conf.template /etc/apache2/
COPY entrypoint.sh /
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ services:
environment:
- WEB_PORT=8089
volumes:
- $PWD/lsky/web:/var/www/html/
- $PWD/web:/var/www/html/
ports:
- "8089:8089"
- "9080:8089"
networks:
- lsky-net

# 注:arm64的无法使用该镜像,请选择sqlite或自建数据库
mysql-lsky:
image: mysql:5.7.22
restart: unless-stopped
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:
networks:
- lsky-net

# 注:arm64的无法使用该镜像,请选择sqlite或自建数据库
mysql-lsky:
image: mysql:5.7.22
restart: unless-stopped
Expand Down

0 comments on commit feefbde

Please sign in to comment.