Skip to content

Commit 4b424dc

Browse files
authored
Docker based deploy (#244)
* Dockerfile to serve production build * Workflow for building and pushing docker image * separate workflows * Temporarily build on pull request * merge jobs * use older ubuntu for build * cleanup
1 parent 9ae0241 commit 4b424dc

File tree

3 files changed

+54
-14
lines changed

3 files changed

+54
-14
lines changed

.github/workflows/deploy.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Deploy build
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
7+
workflow_dispatch:
8+
9+
jobs:
10+
docker:
11+
runs-on: ubuntu-20.04
12+
steps:
13+
-
14+
name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Install dependencies
18+
uses: php-actions/composer@v6
19+
with:
20+
php_version: "7.4"
21+
version: 2
22+
23+
- name: Build
24+
run: |
25+
php7.4 vendor/bin/sculpin generate -vvv -n --env=prod > build_output.log
26+
if grep -iq "notice\|error\|warning" build_output.log ; then return 1; fi
27+
28+
- name: Output
29+
run: cat build_output.log
30+
31+
-
32+
name: Login to Docker Hub
33+
uses: docker/login-action@v3
34+
with:
35+
username: ${{ vars.DOCKERHUB_USERNAME }}
36+
password: ${{ secrets.DOCKERHUB_TOKEN }}
37+
-
38+
name: Set up QEMU
39+
uses: docker/setup-qemu-action@v3
40+
-
41+
name: Set up Docker Buildx
42+
uses: docker/setup-buildx-action@v3
43+
-
44+
name: Build and push
45+
uses: docker/build-push-action@v6
46+
with:
47+
context: .
48+
push: true
49+
tags: phperspl/phpers-website:latest

.github/workflows/main.yml .github/workflows/test.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
name: Test build
22

33
on:
4-
push:
5-
branches: [ master ]
64
pull_request:
75
branches: [ master ]
86

97
workflow_dispatch:
108

119
jobs:
12-
build:
10+
test:
1311
runs-on: ubuntu-20.04
1412

1513
steps:
@@ -27,4 +25,4 @@ jobs:
2725
if grep -iq "notice\|error\|warning" build_output.log ; then return 1; fi
2826
2927
- name: Output
30-
run: cat build_output.log
28+
run: cat build_output.log

Dockerfile

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
FROM php:7.4-alpine
1+
FROM nginx:latest
22

3-
RUN apk add --no-cache git curl
4-
RUN curl -o /usr/bin/composer https://getcomposer.org/download/2.2.6/composer.phar
5-
RUN chmod 755 /usr/bin/composer
6-
7-
VOLUME /app
8-
WORKDIR /app
9-
EXPOSE 8000
10-
11-
CMD ["/usr/bin/composer"]
3+
RUN rm -r /usr/share/nginx/html
4+
COPY output_prod /usr/share/nginx/html

0 commit comments

Comments
 (0)