Refactored the application's dockerization and added new services
This commit involves significant changes to the application's infrastructure. It refactors the application into two separate services: 'nibiru-auth-api' and 'nibiru-webhook-receiver'. Each service has its corresponding Dockerfile, Nginx & PHP-FPM configuration. It also provides a separate Nginx configuration for handling requests for each service. New environment files, start and stop scripts are introduced to facilitate local and production deployments.
This commit is contained in:
38
nibiru-auth-api/fpm/Dockerfile
Normal file
38
nibiru-auth-api/fpm/Dockerfile
Normal file
@@ -0,0 +1,38 @@
|
||||
# Use the official PHP-FPM image for PHP 8.3
|
||||
FROM php:8.3-fpm
|
||||
|
||||
# Import the timezone and virtual port arguments
|
||||
ARG TZ
|
||||
ARG FPM_VIRTUAL_PORT
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /var/www/html
|
||||
|
||||
# Install Composer
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
zip \
|
||||
unzip \
|
||||
git \
|
||||
gettext-base \
|
||||
&& apt-get clean
|
||||
|
||||
# Set the timezone
|
||||
ENV TZ=$TZ
|
||||
RUN echo "date.timezone=${TZ}" > /usr/local/etc/php/conf.d/timezone.ini
|
||||
|
||||
|
||||
# Copy entrypoint script and PHP-FPM configuration template
|
||||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
COPY conf/zz-docker.conf.template /usr/local/etc/php-fpm.d/zz-docker.conf.template
|
||||
|
||||
# Make entrypoint script executable
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
|
||||
# Expose port 9000 for PHP-FPM
|
||||
EXPOSE $FPM_VIRTUAL_PORT
|
||||
|
||||
# Set entrypoint
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
5
nibiru-auth-api/fpm/conf/zz-docker.conf.template
Normal file
5
nibiru-auth-api/fpm/conf/zz-docker.conf.template
Normal file
@@ -0,0 +1,5 @@
|
||||
[global]
|
||||
daemonize = no
|
||||
|
||||
[www]
|
||||
listen = 0.0.0.0:$FPM_VIRTUAL_PORT
|
||||
10
nibiru-auth-api/fpm/entrypoint.sh
Executable file
10
nibiru-auth-api/fpm/entrypoint.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Set the PHP-FPM listen port from the environment variable or default to 9000
|
||||
export FPM_VIRTUAL_PORT=${FPM_VIRTUAL_PORT:-9000}
|
||||
|
||||
# Substitute environment variables in the PHP-FPM configuration template
|
||||
envsubst '$FPM_VIRTUAL_PORT' < /usr/local/etc/php-fpm.d/zz-docker.conf.template > /usr/local/etc/php-fpm.d/zz-docker.conf
|
||||
|
||||
# Start PHP-FPM
|
||||
php-fpm
|
||||
16
nibiru-auth-api/nginx/Dockerfile
Normal file
16
nibiru-auth-api/nginx/Dockerfile
Normal file
@@ -0,0 +1,16 @@
|
||||
FROM nginx:latest
|
||||
|
||||
# Set the timezone
|
||||
ENV TZ=Europe/Berlin
|
||||
|
||||
# Install tzdata for timezone data and gettext for envsubst
|
||||
RUN apt-get update && apt-get install -y tzdata gettext && \
|
||||
ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \
|
||||
dpkg-reconfigure -f noninteractive tzdata
|
||||
|
||||
COPY conf.d /etc/nginx/conf.d
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
40
nibiru-auth-api/nginx/conf.d/default.conf
Normal file
40
nibiru-auth-api/nginx/conf.d/default.conf
Normal file
@@ -0,0 +1,40 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name ${NIBIRU_AUTH_VIRTUAL_HOST};
|
||||
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss;
|
||||
|
||||
location / {
|
||||
proxy_read_timeout 7200;
|
||||
proxy_connect_timeout 7200;
|
||||
if (!-e $request_filename){
|
||||
rewrite ^(.*)$ / break;
|
||||
}
|
||||
root /usr/share/nginx/html;
|
||||
index index.php;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
root /var/www/html;
|
||||
fastcgi_pass ${NIBIRU_AUTH_HOST}:${FPM_VIRTUAL_PORT};
|
||||
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
include fastcgi_params;
|
||||
fastcgi_buffers 16 32k;
|
||||
fastcgi_buffer_size 64k;
|
||||
fastcgi_busy_buffers_size 64k;
|
||||
fastcgi_read_timeout 900;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
40
nibiru-auth-api/nginx/conf.d/default.conf.template
Normal file
40
nibiru-auth-api/nginx/conf.d/default.conf.template
Normal file
@@ -0,0 +1,40 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name ${NIBIRU_AUTH_VIRTUAL_HOST};
|
||||
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss;
|
||||
|
||||
location / {
|
||||
proxy_read_timeout 7200;
|
||||
proxy_connect_timeout 7200;
|
||||
if (!-e $request_filename){
|
||||
rewrite ^(.*)$ / break;
|
||||
}
|
||||
root /usr/share/nginx/html;
|
||||
index index.php;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
root /var/www/html;
|
||||
fastcgi_pass ${NIBIRU_AUTH_HOST}:${FPM_VIRTUAL_PORT};
|
||||
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
include fastcgi_params;
|
||||
fastcgi_buffers 16 32k;
|
||||
fastcgi_buffer_size 64k;
|
||||
fastcgi_busy_buffers_size 64k;
|
||||
fastcgi_read_timeout 900;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
7
nibiru-auth-api/nginx/entrypoint.sh
Executable file
7
nibiru-auth-api/nginx/entrypoint.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Substitute environment variables in the configuration templates
|
||||
envsubst '$NIBIRU_AUTH_HOST $NIBIRU_AUTH_VIRTUAL_HOST $FPM_VIRTUAL_PORT' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Start Nginx
|
||||
exec "$@"
|
||||
Reference in New Issue
Block a user