diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml new file mode 100644 index 0000000..a4572ba --- /dev/null +++ b/.github/workflows/container.yml @@ -0,0 +1,58 @@ +name: Container + +on: + push: + branches: + - main + tags: + - "v*" + pull_request: + +permissions: + contents: read + packages: write + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set image name + run: echo "IMAGE_NAME=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV" + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=tag + type=sha,prefix=sha- + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index b6be7bd..9fc2e83 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,9 @@ -FROM php:apache +FROM php:8.3-apache -# Enable Apache mod_rewrite -RUN a2enmod rewrite - -# Update package list -RUN apt-get update - -# Install Git and GnuPG -RUN apt-get install -y git gnupg2 - -# Install PostgreSQL client and its PHP extensions -RUN apt-get install -y libpq-dev \ - && docker-php-ext-install pdo pdo_pgsql +RUN apt-get update \ + && apt-get install -y --no-install-recommends curl libpq-dev \ + && docker-php-ext-install pdo_pgsql \ + && a2enmod rewrite \ + && rm -rf /var/lib/apt/lists/* COPY ./www /var/www/html/ diff --git a/README.md b/README.md index 44f01b6..c285844 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# PHP Demo Website -[![Better Stack Badge](https://uptime.betterstack.com/status-badges/v2/monitor/1kdio.svg)](https://php-demo.nekofans.net/) [php-demo.nekofans.net](https://php-demo.nekofans.net/) +# PHP Laracasts Demo Website +[![Better Stack Badge](https://uptime.betterstack.com/status-badges/v2/monitor/1kdio.svg)](https://php-laracast.meisterlala.dev/) [php-laracast.meisterlala.dev](https://php-laracast.meisterlala.dev/) This project is part of my journey in mastering PHP, web development, and database management, inspired by my coursework from the [Laracasts PHP Path](https://laracasts.com/series). It showcases a collection of projects that highlight my skills in designing responsive, user-friendly websites, integrating back-end functionality, and managing data with MySQL. @@ -11,8 +11,9 @@ By exploring this demo, you'll gain insight into how I approach full-stack devel - **Database Integration:** Projects include examples of CRUD (Create, Read, Update, Delete) operations with Postgress databases. - **Deployment-Ready:** The project is easily deployable with Docker and can be run seamlessly in any development environment using GitHub Codespaces. -## Check it out: [https://php-demo.nekofans.net/](https://php-demo.nekofans.net/) -Or try the [backup link](https://php-projects.netlify.app) (static site without PHP support) +## Check it out: [https://php-laracast.meisterlala.dev/](https://php-laracast.meisterlala.dev/) + +This site needs PHP and PostgreSQL at runtime, so it is deployed as a Docker container. Static hosts can only serve the landing page and cannot run the PHP routes or database-backed demos. ## Running the Website Locally diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 964ef30..a24260b 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -1,12 +1,14 @@ services: app: - env_file: ".env" + image: ghcr.io/meisterlala/laracasts:latest + build: !reset null + env_file: !override ".env" ports: !reset [] expose: - 80 volumes: !reset "" db: - env_file: ".env" + env_file: !override ".env" pgadmin: !reset "" networks: