Skip to content

Commit

Permalink
add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
eucyt committed May 9, 2023
1 parent ff6b308 commit faf31d2
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish Docker image

on:
release:
types: [ published ]

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: eucyt/mypaper

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# For github action
FROM php:8.2-fpm-buster as builder

COPY ./docker/php/php.ini /usr/local/etc/php/php.ini

COPY ./laravel /laravel
WORKDIR /laravel

RUN apt-get update && \
apt-get -y install git unzip libzip-dev libicu-dev libonig-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
docker-php-ext-install intl pdo_mysql zip bcmath

COPY --from=composer /usr/bin/composer /usr/bin/composer
RUN composer install --no-dev && composer global require "laravel/installer"

RUN if [ ! -d "database/seeds" ]; then mkdir database/seeds; fi
RUN if [ ! -d "database/factories" ]; then mkdir database/factories; fi

RUN php artisan cache:clear \
&& php artisan config:clear \
&& php artisan route:clear \
&& php artisan view:clear

RUN chown -R www-data:www-data storage


FROM php:8.2-apache

COPY ./docker/apache/000-default.conf /etc/apache2/sites-available/
COPY --from=builder /laravel /var/www/laravel

RUN a2ensite 000-default
10 changes: 10 additions & 0 deletions docker/apache/000-default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

<VirtualHost *:80>
DocumentRoot /var/www/laravel/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/laravelapp/public>
AllowOverride All
</Directory>
</VirtualHost>

0 comments on commit faf31d2

Please sign in to comment.