From dd87f0b6f8ab4c7ca830d1a0a07ea9df18b668fb Mon Sep 17 00:00:00 2001 From: Noel Palo Date: Mon, 4 Sep 2023 12:05:18 +0800 Subject: [PATCH] feature/DLT-29-restructure - Update docker compose and file and scripts --- docker/containers/composer/Dockerfile | 4 +- docker/containers/mysql/Dockerfile | 2 +- docker/containers/php/Dockerfile | 3 +- docker/docker-compose.yml | 70 +++++++++++++++------------ scripts/docker-compose.sh | 8 --- scripts/prune.sh | 4 +- 6 files changed, 44 insertions(+), 47 deletions(-) delete mode 100644 scripts/docker-compose.sh diff --git a/docker/containers/composer/Dockerfile b/docker/containers/composer/Dockerfile index ce12d37..8abefaa 100644 --- a/docker/containers/composer/Dockerfile +++ b/docker/containers/composer/Dockerfile @@ -3,8 +3,8 @@ # - use the image tag php:php-8.1-fpm-alpine FROM php:php-8.1-fpm-alpine -# Install Composer 2.1.5 -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --version=2.1.5 +# Install Composer 2.6.1 +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --version=2.6.1 # Add composer bin files path to environment variable RUN export PATH=$PATH":/usr/bin" diff --git a/docker/containers/mysql/Dockerfile b/docker/containers/mysql/Dockerfile index eb91790..03ca982 100644 --- a/docker/containers/mysql/Dockerfile +++ b/docker/containers/mysql/Dockerfile @@ -1,2 +1,2 @@ # Install MySQL -FROM library/mysql:8.0.30 +FROM library/mysql:5.7.22 diff --git a/docker/containers/php/Dockerfile b/docker/containers/php/Dockerfile index f8ccf40..02748e6 100644 --- a/docker/containers/php/Dockerfile +++ b/docker/containers/php/Dockerfile @@ -4,4 +4,5 @@ FROM php:8.1-fpm-alpine # Install PHP Extension RUN apk --no-cache add zip libzip-dev \ && docker-php-ext-configure zip \ - && docker-php-ext-install zip pdo pdo_mysql \ + && docker-php-ext-install zip mysqli pdo pdo_mysql \ + && docker-php-ext-enable pdo_mysql \ diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 13b0d9d..8bd44d6 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.7' +version: '3.8' networks: web-app: @@ -7,7 +7,7 @@ services: # +----------------------+ # # | Container: NginX | # # +----------------------+ # - nginx: + webserver: networks: - web-app container_name: nginx @@ -16,57 +16,58 @@ services: dockerfile: containers/nginx/Dockerfile image: nginx:nginx-stable-alpine ports: - - "9100:80" + - "8080:80" volumes: + - "${PATH_CONFIGS_NGINX}:/etc/nginx/conf.d/default.conf" - "${PATH_PROJECT_SOURCE}:/var/www/html" - - "${PATH_NGINX_CONFIGS}:/etc/nginx/conf.d/default.conf" depends_on: - php - - mysql + - database + + # +----------------------+ # + # | Container: PHP | # + # +----------------------+ # + php: + networks: + - web-app + container_name: php + build: + context: . + dockerfile: containers/php/Dockerfile + image: php:php-8.1-fpm-alpine + ports: + - "9000:9000" + volumes: + - "${PATH_PROJECT_SOURCE}:/var/www/html" # +----------------------+ # # | Container: MySQL | # # +----------------------+ # - mysql: + database: networks: - web-app container_name: mysql - command: mysqld --default-authentication-plugin=mysql_native_password build: context: . dockerfile: containers/mysql/Dockerfile - image: mysql:mysql-8.0.30 + image: mysql:mysql-${DB_VERSION} +# command: mysqld --default-authentication-plugin=mysql_native_password restart: unless-stopped tty: true ports: - "3306:3306" env_file: - - ${PATH_ENV_CONFIGS}/${SYS_ENV}.env + - ${PATH_ENVIRONMENTS}/${SYS_ENV}.env volumes: - "${DB_VOLUME}:/var/lib/mysql" environment: + SERVICE_TAGS: dev + SERVICE_NAME: mysql +# ---- Database Credentials ---- # MYSQL_DATABASE: "${DB_NAME}" # MYSQL_USER: "${DB_USERNAME}" # MYSQL_PASSWORD: "${DB_PASSWORD}" # MYSQL_ROOT_PASSWORD: "${DB_PASSWORD_ROOT}" - SERVICE_TAGS: dev - SERVICE_NAME: mysql - - # +----------------------+ # - # | Container: PHP | # - # +----------------------+ # - php: - networks: - - web-app - container_name: php - build: - context: . - dockerfile: containers/php/Dockerfile - image: php:php-8.1-fpm-alpine - ports: - - "9000:9000" - volumes: - - "${PATH_PROJECT_SOURCE}:/var/www/html" # +----------------------+ # # | Container: Composer | # @@ -78,10 +79,12 @@ services: build: context: . dockerfile: containers/composer/Dockerfile - image: composer:composer-2.1.5 + image: composer:composer-2.6.1 working_dir: /var/www/html volumes: - "${PATH_PROJECT_SOURCE}:/var/www/html" + depends_on: + - php entrypoint: ['composer'] # +----------------------+ # @@ -108,12 +111,15 @@ services: context: . dockerfile: containers/php/Dockerfile image: artisan:laravel-8 + links: + - php + - database env_file: - - ${PATH_ENV_CONFIGS}/config.env - - ${PATH_ENV_CONFIGS}/${SYS_ENV}.env + - ${PATH_ENVIRONMENTS}/${SYS_ENV}.env working_dir: /var/www/html volumes: - "${PATH_PROJECT_SOURCE}:/var/www/html" depends_on: - - mysql - entrypoint: ['/var/www/html/artisan'] + - php + - database + entrypoint: ['php', '/var/www/html/artisan'] diff --git a/scripts/docker-compose.sh b/scripts/docker-compose.sh deleted file mode 100644 index ea816ab..0000000 --- a/scripts/docker-compose.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -eo pipefail - -docker compose \ - --env-file "docker/environments/config.env" \ - -f "docker/docker-compose.yml" \ - ${@} diff --git a/scripts/prune.sh b/scripts/prune.sh index 8531228..295f05d 100644 --- a/scripts/prune.sh +++ b/scripts/prune.sh @@ -2,9 +2,7 @@ set -eo pipefail -#docker rmi -f $(docker images -q) -#docker rmi $(docker images) -#docker rmi $(docker images -qf dangling=true); +# Delete All Images docker system prune -a --force docker ps docker images \ No newline at end of file