From af6b2b752e9d6a5955680a2bfd712a82a6cbe0d7 Mon Sep 17 00:00:00 2001 From: Michel Date: Wed, 30 Oct 2024 19:39:55 +0100 Subject: [PATCH] Moved to caddy and docker for local dev --- deploy/Vagrantfile | 39 ------------------------- deploy/local-testing/Caddyfile | 6 ++++ deploy/local-testing/Dockerfile | 8 +++++ deploy/local-testing/docker-compose.yml | 22 ++++++++++++++ deploy/nginx-file | 11 ------- 5 files changed, 36 insertions(+), 50 deletions(-) delete mode 100644 deploy/Vagrantfile create mode 100644 deploy/local-testing/Caddyfile create mode 100644 deploy/local-testing/Dockerfile create mode 100644 deploy/local-testing/docker-compose.yml delete mode 100644 deploy/nginx-file diff --git a/deploy/Vagrantfile b/deploy/Vagrantfile deleted file mode 100644 index 1ed5e06..0000000 --- a/deploy/Vagrantfile +++ /dev/null @@ -1,39 +0,0 @@ -Vagrant.configure("2") do |config| - config.vm.boot_timeout = 600 - - config.vm.box = "ubuntu/focal64" - - config.vm.network :forwarded_port, guest: 80, host: 1111 - - config.vm.synced_folder "../../games-shop", "/var/www/html" - - config.vm.provision "shell", inline: <<-SHELL - sudo apt update - - # Install dependencies - sudo apt install ca-certificates apt-transport-https software-properties-common lsb-release debian-keyring debian-archive-keyring curl -y - sudo add-apt-repository ppa:ondrej/php -y - - sudo apt update - - sudo apt install nginx php8.3 php8.3-{cli,fpm,curl,gd,zip,fileinfo,common,sqlite3,dom,mbstring,simplexml,xml,xmlreader,xmlwriter} -y - - sudo ufw allow "OpenSSH" - sudo ufw allow "Nginx HTTP" - sudo ufw --force enable - - sudo rm /etc/nginx/sites-enabled/default - sudo ln -s /var/www/html/deploy/nginx-file /etc/nginx/sites-enabled/default - - sudo systemctl enable --now nginx - sudo systemctl restart nginx - - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" - php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" - php composer-setup.php - php -r "unlink('composer-setup.php');" - - sudo mv composer.phar /usr/local/bin/composer - - SHELL -end diff --git a/deploy/local-testing/Caddyfile b/deploy/local-testing/Caddyfile new file mode 100644 index 0000000..61790cc --- /dev/null +++ b/deploy/local-testing/Caddyfile @@ -0,0 +1,6 @@ +:80 { + root * /app/public + encode gzip + php_fastcgi php-fpm:9000 + file_server +} \ No newline at end of file diff --git a/deploy/local-testing/Dockerfile b/deploy/local-testing/Dockerfile new file mode 100644 index 0000000..46e8f87 --- /dev/null +++ b/deploy/local-testing/Dockerfile @@ -0,0 +1,8 @@ +FROM php:8.3-fpm + +RUN apt-get update && \ + apt-get install -y \ + libzip-dev libpng-dev +RUN docker-php-ext-install zip + +RUN docker-php-ext-install gd \ No newline at end of file diff --git a/deploy/local-testing/docker-compose.yml b/deploy/local-testing/docker-compose.yml new file mode 100644 index 0000000..91f31b2 --- /dev/null +++ b/deploy/local-testing/docker-compose.yml @@ -0,0 +1,22 @@ +services: + caddy: + container_name: gamesshop_caddy + image: caddy + ports: + - 8080:80 + volumes: + - ./Caddyfile:/etc/caddy/Caddyfile + - ./../..:/app + - caddy_config:/config + - caddy_data:/data + depends_on: + - php-fpm + php-fpm: + container_name: gamesshop_php + build: . + volumes: + - ./../..:/app + +volumes: + caddy_data: + caddy_config: \ No newline at end of file diff --git a/deploy/nginx-file b/deploy/nginx-file deleted file mode 100644 index 911386f..0000000 --- a/deploy/nginx-file +++ /dev/null @@ -1,11 +0,0 @@ -server { - listen 80 default_server; - listen [::]:80 default_server; - - root /var/www/html/public; - location / { - include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root/index.php; - fastcgi_pass unix:/var/run/php/php8.3-fpm.sock; - } -} \ No newline at end of file