From 5a199fccb4431cfbf7aa6e4e3ea16c4a465b3540 Mon Sep 17 00:00:00 2001 From: glovetleong Date: Thu, 27 Oct 2022 00:48:18 +0800 Subject: [PATCH 1/3] docker setup --- docker-setup/Dockerfile | 28 ++++++++++++++++++++++++++++ docker-setup/nginx/default.conf | 27 +++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 docker-setup/Dockerfile create mode 100644 docker-setup/nginx/default.conf diff --git a/docker-setup/Dockerfile b/docker-setup/Dockerfile new file mode 100644 index 00000000..13ce0249 --- /dev/null +++ b/docker-setup/Dockerfile @@ -0,0 +1,28 @@ +FROM php:7.4-fpm + +WORKDIR /var/www/html + +RUN docker-php-ext-install pdo pdo_mysql + +RUN apt-get update && apt-get install -y \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libpng-dev \ + libzip-dev \ + zip \ + cron \ + supervisor \ + nano \ + && docker-php-ext-configure gd --with-freetype --with-jpeg \ + && docker-php-ext-install -j$(nproc) gd \ + && docker-php-ext-install zip \ + && docker-php-ext-install bcmath + +COPY --from=composer:1.9.3 /usr/bin/composer /usr/bin/composer + +#NODEJS & NPM +RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - +RUN apt-get -y install nodejs + +RUN chown -R www-data:www-data /var/www +RUN chmod 755 /var/www \ No newline at end of file diff --git a/docker-setup/nginx/default.conf b/docker-setup/nginx/default.conf new file mode 100644 index 00000000..8761015c --- /dev/null +++ b/docker-setup/nginx/default.conf @@ -0,0 +1,27 @@ +server { + listen 80; + index index.php index.html; + server_name localhost; + error_log /var/log/nginx/error.log; + access_log /var/log/nginx/access.log; + root /var/www/html/public; + + server_name localhost; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ \.php$ { + try_files $uri =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php: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_intercept_errors on; + fastcgi_keep_conn on; + fastcgi_param PHP_VALUE "auto_prepend_file= \n allow_url_include=Off"; + } +} \ No newline at end of file From 9a10919f4c8ddab4354385e0e7f3420e00b2b19c Mon Sep 17 00:00:00 2001 From: glovetleong Date: Thu, 27 Oct 2022 00:52:21 +0800 Subject: [PATCH 2/3] docker-compose.yml --- .gitignore | 1 - docker-setup/docker-compose.yml | 51 +++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 docker-setup/docker-compose.yml diff --git a/.gitignore b/.gitignore index 476bf6a0..095342e0 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,6 @@ gox.iml rebuild_docker.sh docker/* db/* -docker-compose.yml package-lock.json public/* /public/* diff --git a/docker-setup/docker-compose.yml b/docker-setup/docker-compose.yml new file mode 100644 index 00000000..3a46a193 --- /dev/null +++ b/docker-setup/docker-compose.yml @@ -0,0 +1,51 @@ +version: '3' + +networks: + exchange-staging: + +services: + ################################################################# + nginx: + image: nginx:stable-alpine + container_name: exchange-ngnix + ports: + - "8081:80" + volumes: + - ../:/var/www/html + - ./nginx/default.conf:/etc/nginx/conf.d/default.conf + depends_on: + - php + - mysql + networks: + - exchange-staging + ################################################################# + mysql: + image: mysql:5.7.29 + container_name: exchange-mysql + restart: unless-stopped + tty: true + ports: + - 3307:3306 + environment: + MYSQL_ROOT_USER: root + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: exchange-db + MYSQL_USER: master + MYSQL_PASSWORD: cDe7gcrRBWetaAP + volumes: + - /var/docker/lib/mysql:/var/lib/mysql + networks: + - exchange-staging + ################################################################# + php: + build: + context: . + dockerfile: Dockerfile + container_name: exchange-php + volumes: + - ../:/var/www/html + ports: + - "9001:9000" + networks: + - exchange-staging + ################################################################# \ No newline at end of file From d21d97d957833cabc1eac4c903aad28b9a354626 Mon Sep 17 00:00:00 2001 From: Dillon Date: Wed, 2 Nov 2022 05:53:59 +0800 Subject: [PATCH 3/3] Update mapping --- docker-setup/docker-compose.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docker-setup/docker-compose.yml b/docker-setup/docker-compose.yml index 3a46a193..deb02207 100644 --- a/docker-setup/docker-compose.yml +++ b/docker-setup/docker-compose.yml @@ -9,7 +9,7 @@ services: image: nginx:stable-alpine container_name: exchange-ngnix ports: - - "8081:80" + - "8082:80" volumes: - ../:/var/www/html - ./nginx/default.conf:/etc/nginx/conf.d/default.conf @@ -25,7 +25,7 @@ services: restart: unless-stopped tty: true ports: - - 3307:3306 + - 3302:3306 environment: MYSQL_ROOT_USER: root MYSQL_ROOT_PASSWORD: root @@ -33,7 +33,7 @@ services: MYSQL_USER: master MYSQL_PASSWORD: cDe7gcrRBWetaAP volumes: - - /var/docker/lib/mysql:/var/lib/mysql + - mysql-data:/var/lib/mysql networks: - exchange-staging ################################################################# @@ -45,7 +45,10 @@ services: volumes: - ../:/var/www/html ports: - - "9001:9000" + - "9002:9000" networks: - exchange-staging - ################################################################# \ No newline at end of file + ################################################################# + +volumes: + mysql-data: