Skip to content

Commit

Permalink
add github action
Browse files Browse the repository at this point in the history
  • Loading branch information
eucyt committed May 13, 2023
1 parent 2c3aca8 commit 63ee950
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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/mynote-backend

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

COPY ./docker/php/php.ini /usr/local/etc/php/php.ini
COPY ./docker/apache/000-default.conf /etc/apache2/sites-available/
COPY ./laravel /var/www/laravel
WORKDIR /var/www/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

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 63ee950

Please sign in to comment.