Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
635406e
chore: update readme;
Kasui92 Oct 18, 2024
8dde55a
chore: update LICENSE reference;
Kasui92 Oct 18, 2024
ec36503
ref: add libraries;
Kasui92 Oct 18, 2024
3747946
upd: migrate to www;
Kasui92 Oct 18, 2024
dd72b59
ref: add first command test;
Kasui92 Oct 18, 2024
7dcf1dd
fix: add stack version check
Kasui92 Oct 18, 2024
3779bda
fix: add logo and version info;
Kasui92 Oct 22, 2024
bb54682
fix: remove ENV variable
Kasui92 Oct 22, 2024
9cd1013
fix: rename test command;
Kasui92 Oct 22, 2024
64aedd4
fix: use common compose for database
Kasui92 Oct 22, 2024
cc6e4d9
upd: add initial commands set
Kasui92 Oct 22, 2024
412ba84
fix: remove optional service from base
Kasui92 Oct 23, 2024
b6b8424
ref: implement webserver service;
Kasui92 Oct 23, 2024
a366213
upd: upgrade mysql version
Kasui92 Oct 23, 2024
acb3f63
feat: add webserver commands;
Kasui92 Oct 23, 2024
33bd148
Fix: container nginx,php-fpm non funzionante (#12)
emyreax Oct 24, 2024
9b11197
fix: correct other php Dockerfile;
Kasui92 Oct 28, 2024
3b777a7
fix: correct command name in service usage
Kasui92 Oct 28, 2024
657a1c9
fix: update GitHub repository URL in version check script
Kasui92 Dec 26, 2024
838a3c9
feat: add database commands
Kasui92 Dec 26, 2024
d964b70
feat: add service management commands and configuration
Kasui92 Dec 29, 2024
bf32750
fix: improve service enable/disable functions with error handling and…
Kasui92 Dec 29, 2024
0b207c8
fix: typo
Kasui92 Dec 29, 2024
d410861
feat: add recreate command to manage Docker containers and networks
Kasui92 Dec 29, 2024
58fc4d6
fix: update JSON parsing to correctly retrieve enabled services
Kasui92 Dec 29, 2024
f310340
feat: add start, stop, and restart commands for Mailhog and PhpMyAdmi…
Kasui92 Dec 29, 2024
e4eae51
feat: add list command to display all optional services with their st…
Kasui92 Dec 29, 2024
11bd8e3
refactor: replace services.json with a simpler services file and upda…
Kasui92 Dec 31, 2024
8bee8a9
fix: remove version from .gitignore to ensure it is tracked
Kasui92 Dec 31, 2024
3d67cc0
feat: update README.md
Kasui92 Dec 31, 2024
f3e8a41
feat: add database export, import, and refresh commands
Kasui92 Dec 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 22 additions & 31 deletions .docker/compose.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,36 @@
services:

php:
webserver:
build:
context: "services/php"
dockerfile: "Dockerfile.${PHP_VERSION}"
context: "${STACK_DIR}"
dockerfile: "${STACK_DIR}/.docker/services/webserver/version/${PHP_VERSION}/Dockerfile"
args:
uid: "${PHP_UID}"
image: "${PROJECT}_php"
container_name: "${PROJECT}_php"
image: "${PROJECT}_webserver"
container_name: "${PROJECT}_webserver"
ports:
- "${SERVICE_PORT}:80"
volumes:
- ./services/php/config/conf.d:/usr/local/etc/php/conf.d:ro
- ../service:/var/www/html
# Log
- "${STACK_DIR}/logs/nginx:/var/log/nginx"
# PHP
- "${STACK_DIR}/.docker/services/webserver/config/conf.d:/usr/local/etc/php/conf.d:ro"
# Web
- "${STACK_DIR}/www:/var/www/html"
environment:
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}

nginx:
build:
context: "services/nginx"
image: "${PROJECT}_nginx"
container_name: "${PROJECT}_nginx"
ports:
- "${SERVICE_PORT}:80"
- "${PMA_PORT}:8080"
volumes:
- ../service:/var/www/html
- ./services/nginx/config/conf.d:/etc/nginx/conf.d
- ../logs/nginx:/var/log/nginx
- phpmyadmin-data:/var/www/phpmyadmin
depends_on:
- php

database:
build:
context: "services/database"
image: "${PROJECT}_database"
container_name: "${PROJECT}_database"
#restart: // always;unless-stopped
ports:
- "${DB_PORT}:3306"
volumes:
- ./services/database/config/conf.d/my.cnf:/etc/mysql/conf.d/my.cnf
- database-data:/var/lib/mysql
- "${STACK_DIR}/.docker/services/database/config/conf.d/my.cnf:/etc/mysql/conf.d/my.cnf"
- "database-data:/var/lib/mysql"
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
Expand All @@ -53,21 +42,23 @@ services:
context: "services/phpmyadmin"
image: "${PROJECT}_phpmyadmin"
container_name: "${PROJECT}_phpmyadmin"
volumes:
- phpmyadmin-data:/var/www/html
ports:
- "${PMA_PORT}:80"
environment:
PMA_HOST: database
- PMA_HOST=database
depends_on:
- database
profiles: ["phpmyadmin"]

mailhog:
build:
context: "services/mailhog"
image: "${PROJECT}_mailhog"
container_name: "${PROJECT}_mailhog"
#restart: always
ports:
- "${MAILHOG_PORT}:8025"
profiles: ["mailhog"]

# Volumes
volumes:
database-data:
phpmyadmin-data:
2 changes: 1 addition & 1 deletion .docker/services/database/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM mysql:5.7
FROM mysql:8.0
1 change: 0 additions & 1 deletion .docker/services/database/config/conf.d/my.cnf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[mysqld]
collation-server = utf8mb4_unicode_ci
character-set-server = utf8mb4
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
default_time_zone = Europe/Rome
9 changes: 0 additions & 9 deletions .docker/services/nginx/Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions .docker/services/nginx/config/conf.d/phpmyadmin.conf

This file was deleted.

18 changes: 0 additions & 18 deletions .docker/services/nginx/config/example.php.conf

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@ extension=zip.so
; http://php.net/date.timezone
date.timezone = "Europe/Rome"

; Xdebug
; See https://xdebug.org/docs/all_settings

;PHPStorm
[Xdebug]
xdebug.remote_enable=1
xdebug.idekey=PHPSTORM
xdebug.profiler_enable=0
xdebug.max_nesting_level=700
xdebug.remote_host=192.168.0.1 # your ip
xdebug.remote_port=9000

; INTL Extension
[intl]
intl.default_locale =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ group = www-data
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = nginx:9000
listen = 127.0.0.0:9000


; Choose how the process manager will control the number of child processes.
Expand Down Expand Up @@ -72,4 +72,4 @@ pm.min_spare_servers = 1
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 3

;---------------------
;---------------------
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ server {
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_pass 127.0.0.0:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
}
7 changes: 7 additions & 0 deletions .docker/services/webserver/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -e

# PHP > Start services
service memcached start
php-fpm -D
nginx -g 'daemon off;'
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,6 @@ RUN echo "Install PHP Intl" \
&& docker-php-ext-enable intl \
&& rm -rf /tmp/*

# Install xdebug
RUN echo "Install xDebug" \
&& pecl install xdebug-2.5.5 \
&& docker-php-ext-enable xdebug

# Install redis
RUN echo "Install Redis" \
&& pecl install redis-2.2.8 \
&& docker-php-ext-enable redis

# Install sendmailer for Mailhog
RUN curl --location --output /usr/local/bin/mhsendmail https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 \
&& chmod +x /usr/local/bin/mhsendmail
Expand All @@ -87,20 +77,43 @@ RUN apt-get remove -y libmcrypt-dev libicu-dev libpng-dev libjpeg-dev libfreetyp
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/*

# -------------------------------------------------------
# SERVE STAGE
# -------------------------------------------------------

# Get API Base Image
FROM base-stage AS serve-stage

# Arguments defined in compose.yml
ARG uid

# Install serve dependencies
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get -y --no-install-recommends install \
nginx \
memcached \
ssl-cert

# Clean up, try to reduce image size
RUN apt-get autoremove -y \
&& apt-get clean all \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/*

# Add user for web application
RUN groupadd -g $uid www
RUN useradd -u $uid -ms /bin/bash -g www www
# Generate ssl certificate
RUN make-ssl-cert generate-default-snakeoil --force-overwrite

# Copy existing application directory contents
COPY . /var/www/html
# Copy nginx config
COPY .docker/services/webserver/config/sites-available/default.nginx /etc/nginx/sites-available/default

# Copy existing application directory permissions
COPY --chown=www:www . /var/www/html
# Copy entrypoint
COPY .docker/services/webserver/entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
RUN ln -s /usr/local/bin/entrypoint.sh /

# Change current user to www
USER www
# Specify the entrypoint
ENTRYPOINT ["entrypoint.sh"]

# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]
# Set working dir
WORKDIR /var/www/html
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Create image based on the official PHP-FMP image
FROM php:7.4-fpm-buster
# -------------------------------------------------------
# BASE STAGE
# -------------------------------------------------------

# Arguments defined in docker-compose.yml
ARG uid
# Create image based on the official PHP-FMP image
FROM php:7.4-fpm-buster AS base-stage

# Update the base libraries
RUN apt-get -y update --fix-missing && apt-get upgrade -y
Expand Down Expand Up @@ -35,7 +36,7 @@ RUN apt-get -y --no-install-recommends install --fix-missing \
libmemcached-dev \
zlib1g-dev

# Other PHP5.6 Extensions
# Other PHP Extensions
RUN echo "Installing PHP extensions" && \
docker-php-ext-install pdo_mysql \
pdo_sqlite \
Expand All @@ -50,7 +51,7 @@ RUN echo "Installing PHP extensions" && \
docker-php-ext-configure gd --with-freetype=/usr/include --with-jpeg=/usr/include && \
docker-php-ext-install gd

# Other PHP5.6 Extensions
# Other PHP Extensions
RUN echo "Enabling PHP extensions" && \
docker-php-ext-enable pdo_mysql pdo_sqlite mysqli zip

Expand All @@ -61,16 +62,6 @@ RUN echo "Install PHP Intl" \
&& docker-php-ext-enable intl \
&& rm -rf /tmp/*

# Install xdebug
RUN echo "Install xDebug" \
&& pecl install xdebug-2.9.2 \
&& docker-php-ext-enable xdebug

# Install redis
RUN echo "Install Redis" \
&& pecl install redis-5.3.4 \
&& docker-php-ext-enable redis

# Install sendmailer for Mailhog
RUN curl --location --output /usr/local/bin/mhsendmail https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 \
&& chmod +x /usr/local/bin/mhsendmail
Expand All @@ -82,20 +73,43 @@ RUN apt-get remove -y libmcrypt-dev libicu-dev libpng-dev libjpeg-dev libfreetyp
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/*

# -------------------------------------------------------
# SERVE STAGE
# -------------------------------------------------------

# Get API Base Image
FROM base-stage AS serve-stage

# Arguments defined in compose.yml
ARG uid

# Install serve dependencies
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get -y --no-install-recommends install \
nginx \
memcached \
ssl-cert

# Clean up, try to reduce image size
RUN apt-get autoremove -y \
&& apt-get clean all \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/*

# Add user for web application
RUN groupadd -g $uid www
RUN useradd -u $uid -ms /bin/bash -g www www
# Generate ssl certificate
RUN make-ssl-cert generate-default-snakeoil --force-overwrite

# Copy existing application directory contents
COPY . /var/www/html
# Copy nginx config
COPY .docker/services/webserver/config/sites-available/default.nginx /etc/nginx/sites-available/default

# Copy existing application directory permissions
COPY --chown=www:www . /var/www/html
# Copy entrypoint
COPY .docker/services/webserver/entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
RUN ln -s /usr/local/bin/entrypoint.sh /

# Change current user to www
USER www
# Specify the entrypoint
ENTRYPOINT ["entrypoint.sh"]

# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]
# Set working dir
WORKDIR /var/www/html
Loading