Skip to content

Commit

Permalink
chore: create docker deployment workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rise-erpelding committed Oct 19, 2023
1 parent 48ce674 commit 45c98d7
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 3 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ node_modules
package-lock.json
package.json
php.ini
plugins
src
tasks
test
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/deploy.docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build Docker Image

on:
push:
branches: [main]
workflow_dispatch:

jobs:
deploy:
if: ${{ vars.DEPLOY_WITH_DOCKER }}
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install npm dependencies
run: npm ci

- name: Install custom plugin npm dependencies
run: npm run plugins:install

- name: Install PHP dependencies with Composer
uses: php-actions/composer@v6
with:
php_version: '8.1'
version: 2.x

- name: Run tests
run: npm test

- name: Build theme
run: npm run build:prod

- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GH_TOKEN}}

- name: 'Build Inventory Image'
run: |
docker build . --tag ghcr.io/sparkbox/sparkpress:latest
docker push ghcr.io/sparkbox/sparkpress:latest
12 changes: 11 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM php:8.1-apache-buster
FROM php:8.1-apache-buster as dev

LABEL org.opencontainers.image.source=https://github.com/sparkbox/sparkpress-wordpress-starter

# When changings, also change in .circleci/config.yml
ENV WP_VERSION=6.3.1
Expand Down Expand Up @@ -36,3 +38,11 @@ RUN find /var/www/ -type f -exec chmod 644 {} \;
# make the linters executable so we can run them from containers
RUN chmod +x vendor/bin/phpcs
RUN chmod +x vendor/bin/twigcs

FROM dev as prod

COPY theme /var/www/html/wp-content/themes/sparkpress-theme
COPY plugins /var/www/html/wp-content/plugins
COPY wp-configs/wp-config.php /var/www/html/wp-config.php
COPY wp-configs/php.ini /var/www/html/php.ini
COPY wp-configs/.htaccess /var/www/html/.htaccess
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ version: '3.7'

services:
web:
build: .
build:
context: .
target: dev
container_name: sparkpress
ports:
- '8000:80'
Expand Down

0 comments on commit 45c98d7

Please sign in to comment.