Skip to content

Instantly share code, notes, and snippets.

@jswebschmiede
Last active May 18, 2024 09:24
Show Gist options
  • Save jswebschmiede/a0c94dedbd0670ec804511adead85ce0 to your computer and use it in GitHub Desktop.
Save jswebschmiede/a0c94dedbd0670ec804511adead85ce0 to your computer and use it in GitHub Desktop.

Revisions

  1. jswebschmiede revised this gist May 18, 2024. 3 changed files with 27 additions and 32 deletions.
    17 changes: 16 additions & 1 deletion Dockerfile
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,19 @@

    FROM php:fpm

    RUN docker-php-ext-install pdo pdo_mysql
    RUN groupadd -g 1000 develop && \
    useradd -u 1000 -g 1000 -m develop

    RUN apt-get update && \
    apt-get install -y zip libzip-dev libmagickwand-dev zlib1g-dev libpng-dev libjpeg-dev --no-install-recommends && \
    rm -rf /var/lib/apt/lists/*

    RUN docker-php-ext-configure zip

    RUN docker-php-ext-configure gd --with-jpeg

    RUN mkdir -p /usr/src/php/ext/imagick; \
    curl -fsSL https://github.com/Imagick/imagick/archive/06116aa24b76edaf6b1693198f79e6c295eda8a9.tar.gz | tar xvz -C "/usr/src/php/ext/imagick" --strip 1 && \
    docker-php-ext-install gd imagick pdo pdo_mysql zip;

    USER develop
    7 changes: 5 additions & 2 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -6,16 +6,19 @@ services:
    - 80:80
    volumes:
    - ./nginx/nginx.conf:/etc/nginx/nginx.conf
    - ./app:/app
    - ./app:/home/develop/www/app
    networks:
    - web
    php:
    image: my-php
    build: services/php
    volumes:
    - ./app:/app
    - ./app:/home/develop/www/app
    user: '1000:1000'
    networks:
    - web
    extra_hosts:
    - 'host.docker.internal:host-gateway'
    db:
    image: mariadb:latest
    restart: unless-stopped
    35 changes: 6 additions & 29 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,16 @@
    #put this file in folder /nginx/

    events {
    worker_connections 4096; ## Default: 1024
    }

    http {
    include mime.types;
    default_type application/octet-stream;
    keepalive_timeout 65;

    server {
    listen 80;
    server_name phplearning.local;
    root /app/public;
    server_name php.local;
    root /home/develop/www/app/public;

    index index.php index.html;

    @@ -22,29 +24,4 @@ http {
    include fastcgi_params;
    }
    }

    types {
    text/css css;
    text/html html htm shtml;
    text/xml xml;
    image/gif gif;
    image/jpeg jpeg jpg;
    application/x-javascript js;
    application/atom+xml atom;
    application/rss+xml rss;
    image/png png;
    image/svg+xml svg svgz;
    image/webp webp;
    video/mp4 mp4;
    audio/mpeg mp3;
    application/font-woff woff;
    application/font-woff2 woff2;
    application/vnd.ms-fontobject eot;
    application/x-font-ttf ttf;
    application/json json;
    application/ld+json jsonld;
    application/x-web-app-manifest+json webapp;
    text/cache-manifest appcache;
    text/x-component htc;
    }
    }
  2. jswebschmiede created this gist May 8, 2024.
    5 changes: 5 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    #Dockerfile needs to be in folder /services/php

    FROM php:fpm

    RUN docker-php-ext-install pdo pdo_mysql
    44 changes: 44 additions & 0 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    services:
    web:
    image: nginx:alpine
    restart: unless-stopped
    ports:
    - 80:80
    volumes:
    - ./nginx/nginx.conf:/etc/nginx/nginx.conf
    - ./app:/app
    networks:
    - web
    php:
    image: my-php
    build: services/php
    volumes:
    - ./app:/app
    networks:
    - web
    db:
    image: mariadb:latest
    restart: unless-stopped
    env_file:
    - ./.env
    volumes:
    - mysqldata:/var/lib/mysql
    ports:
    - 3306:3306
    networks:
    - web
    phpmyadmin:
    image: 'phpmyadmin:latest'
    ports:
    - 8080:80
    networks:
    - web
    environment:
    - PMA_ARBITRARY=1
    - PMA_HOST=db
    depends_on:
    - db
    volumes:
    mysqldata: {}
    networks:
    web:
    50 changes: 50 additions & 0 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    #put this file in folder /nginx/

    events {
    worker_connections 4096; ## Default: 1024
    }

    http {
    server {
    listen 80;
    server_name phplearning.local;
    root /app/public;

    index index.php index.html;

    location / {
    autoindex on;
    }

    location ~ \.php$ {
    fastcgi_pass php:9000;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }
    }

    types {
    text/css css;
    text/html html htm shtml;
    text/xml xml;
    image/gif gif;
    image/jpeg jpeg jpg;
    application/x-javascript js;
    application/atom+xml atom;
    application/rss+xml rss;
    image/png png;
    image/svg+xml svg svgz;
    image/webp webp;
    video/mp4 mp4;
    audio/mpeg mp3;
    application/font-woff woff;
    application/font-woff2 woff2;
    application/vnd.ms-fontobject eot;
    application/x-font-ttf ttf;
    application/json json;
    application/ld+json jsonld;
    application/x-web-app-manifest+json webapp;
    text/cache-manifest appcache;
    text/x-component htc;
    }
    }