Skip to content

Commit

Permalink
feat: Dockerize it
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejsika committed Apr 12, 2024
1 parent ed4944a commit 64836e4
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build and Push Docker Image to GHCR

on:
push:
branches:
- master

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Build PHP
run: docker buildx build -f Dockerfile.php -t ghcr.io/${{ github.actor }}/cro-php-example:php .

- name: Build Nginx
run: docker buildx build -f Dockerfile.nginx -t ghcr.io/${{ github.actor }}/cro-php-example:nginx .

- name: Push PHP
run: docker push ghcr.io/${{ github.actor }}/cro-php-example:php

- name: Push Nginx
run: docker push ghcr.io/${{ github.actor }}/cro-php-example:nginx
5 changes: 5 additions & 0 deletions Dockerfile.nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM nginx
WORKDIR /app
COPY index.php .
COPY nginx-site.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
3 changes: 3 additions & 0 deletions Dockerfile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM php:8.3-fpm
WORKDIR /var/www/html
COPY /index.php .
22 changes: 22 additions & 0 deletions nginx-site.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
server {
server_name _;
listen [::]:80;
listen 80;

root /app;

location / {
try_files $uri /index.php$is_args$args;
}

location ~ .php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_intercept_errors on;
}
}

0 comments on commit 64836e4

Please sign in to comment.