Skip to content

Commit 86d3f62

Browse files
committed
Treewide: Docker: Introduce Minio S3 Object Storage !
Signed-off-by: Dicky Herlambang (花) <[email protected]>
1 parent ca4d544 commit 86d3f62

8 files changed

+127
-136
lines changed

Dockerfile/Dockerfile.hana-api-services.sit

+44-20
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,30 @@ RUN apk add --no-cache \
2424
curl \
2525
unzip \
2626
git \
27-
imagemagick-dev \
2827
libzip-dev \
2928
freetype-dev \
29+
imagemagick-dev \
3030
libjpeg-turbo-dev \
3131
libpng-dev \
3232
ghostscript \
3333
python3 \
3434
py3-pip \
35-
postgresql-dev \
3635
autoconf \
3736
build-base \
38-
libsodium-dev
37+
postgresql-dev \
38+
libsodium-dev \
39+
supervisor \
40+
nginx \
41+
bash \
42+
busybox-suid \
43+
nano
3944

4045
# Install PHP extensions
4146
RUN docker-php-ext-configure gd --with-freetype --with-jpeg && \
4247
docker-php-ext-install -j$(nproc) gd zip pdo_pgsql ftp sodium
4348

4449
# Install Imagick extension
45-
RUN curl -L -o /tmp/imagick.tar.gz https://github.com/Imagick/imagick/archive/refs/tags/3.7.0.tar.gz \
50+
RUN cd /tmp && curl -L -o /tmp/imagick.tar.gz https://pecl.php.net/get/imagick-3.7.0.tgz \
4651
&& tar --strip-components=1 -xf /tmp/imagick.tar.gz \
4752
&& phpize \
4853
&& ./configure \
@@ -57,27 +62,28 @@ RUN pip3 install --upgrade pip && pip3 install requests
5762

5863
# Clone App Services
5964
RUN git clone -b dev/be/master https://github.com/Nicklas373/Hana-PDF hanaci-api
60-
RUN chown -R www-data:www-data hanaci-api
6165

6266
# Configure Composer
6367
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
6468
RUN cd hanaci-api && composer install --no-interaction --no-scripts --no-progress --prefer-dist
6569

6670
# Configure App Service
6771
COPY module/php/php.ini /usr/local/etc/php/conf.d/99-hana.ini
68-
RUN mkdir -p hanaci-api/storage/app/public/batch
69-
RUN mkdir -p hanaci-api/storage/app/public/download
70-
RUN mkdir -p hanaci-api/storage/app/public/image
71-
RUN mkdir -p hanaci-api/storage/app/public/pool
72-
RUN mkdir -p hanaci-api/storage/app/public/upload
72+
RUN cd hanaci-api && \
73+
mkdir -p hanaci-api/storage/app/public/batch && \
74+
mkdir -p hanaci-api/storage/app/public/download && \
75+
mkdir -p hanaci-api/storage/app/public/image && \
76+
mkdir -p hanaci-api/storage/app/public/pool && \
77+
mkdir -p hanaci-api/storage/app/public/upload
78+
RUN cd hanaci-api && cp .env.example .env
79+
RUN cd hanaci-api && \
80+
php artisan key:generate --no-interaction --quiet && \
81+
php artisan jwt:secret --no-interaction --quiet && \
82+
php artisan storage:link --no-interaction --quiet && \
83+
php artisan config:cache --quiet && \
84+
php artisan config:clear --quiet
7385
RUN cd hanaci-api && chmod o+w /var/www/html/hanaci-api/storage/ -R
7486
RUN cd hanaci-api && chmod o+w /var/www/html/hanaci-api/vendor/mpdf/mpdf/tmp/ -R
75-
RUN cd hanaci-api && cp .env.example .env
76-
RUN cd hanaci-api && php artisan key:generate
77-
RUN cd hanaci-api && php artisan jwt:secret
78-
RUN cd hanaci-api && php artisan storage:link
79-
RUN cd hanaci-api && php artisan config:cache
80-
RUN cd hanaci-api && php artisan config:clear
8187

8288
# Configure Laravel Env
8389
RUN cd hanaci-api && echo "" >> .env
@@ -107,8 +113,26 @@ RUN cd hanaci-api && echo "TELEGRAM_BOT_ID=xxxx" >> .env
107113
RUN cd hanaci-api && echo "TELEGRAM_CHAT_ID=xxxx" >> .env
108114
RUN cd hanaci-api && echo "HANA_UNIQUE_KEY=xxxx" >> .env
109115

110-
# Expose port 9000
111-
EXPOSE 9000
116+
# Configure permission
117+
RUN cd hanaci-api && \
118+
chmod o+w /var/www/html/hanaci-api/storage/ -R && \
119+
chmod o+w /var/www/html/hanaci-api/vendor/mpdf/mpdf/tmp/ -R
120+
121+
# Configure Nginx Services
122+
RUN mkdir /etc/nginx/sites-enabled
123+
COPY module/nginx/nginx.conf /etc/nginx/nginx.conf
124+
COPY module/nginx/sites-available/api-hanaci.conf /etc/nginx/sites-available/api-hanaci.conf
125+
RUN ln -s /etc/nginx/sites-available/api-hanaci.conf /etc/nginx/sites-enabled/
126+
127+
# Set up cron job for Laravel scheduler
128+
COPY module/hanaci/hanaci-api/api-cron /etc/crontabs/root
129+
RUN touch /var/log/cron.log && chmod 0644 /var/log/cron.log
130+
131+
# Configure supervisord
132+
COPY module/instance/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
133+
134+
# Expose necessary ports
135+
EXPOSE 80 9000
112136

113-
# Start PHP FPM
114-
CMD ["php-fpm"]
137+
# Start cron, Nginx, and PHP-FPM with supervisord
138+
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

Dockerfile/Dockerfile.hana-app-pdf.sit

+33-11
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,35 @@ RUN apk add --no-cache \
2525
unzip \
2626
git \
2727
libzip-dev \
28-
postgresql-dev
28+
libpq-dev \
29+
postgresql-dev \
30+
supervisor \
31+
nginx \
32+
bash \
33+
busybox-suid \
34+
nano
2935

3036
# Install PHP extensions
31-
RUN docker-php-ext-install zip pdo_pgsql
37+
RUN docker-php-ext-install -j$(nproc) pdo_pgsql
3238

3339
# Clone App Services
3440
RUN git clone -b dev/fe/master-live https://github.com/Nicklas373/Hana-PDF hanaci-pdf
35-
RUN chown -R www-data:www-data hanaci-pdf
3641

3742
# Configure Composer
3843
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
3944
RUN cd hanaci-pdf && composer install --no-interaction --no-scripts --no-progress --prefer-dist
4045

4146
# Configure App Service
4247
COPY module/php/php.ini /usr/local/etc/php/conf.d/99-hana.ini
43-
RUN cd hanaci-pdf && chmod o+w /var/www/html/hanaci-pdf/storage/ -R
4448
RUN cd hanaci-pdf && cp .env.example .env
45-
RUN cd hanaci-pdf && php artisan key:generate
46-
RUN cd hanaci-pdf && php artisan config:cache
47-
RUN cd hanaci-pdf && php artisan config:clear
49+
RUN cd hanaci-pdf && \
50+
php artisan key:generate && \
51+
php artisan config:cache && \
52+
php artisan config:clear
53+
54+
# Configure permission
55+
RUN cd hanaci-pdf && \
56+
chmod o+w /var/www/html/hanaci-pdf/storage/ -R
4857

4958
# Configure Laravel Env
5059
RUN cd hanaci-pdf && echo "VITE_ADOBE_CLIENT_ID=xxxx" >> .env
@@ -60,8 +69,21 @@ RUN cd hanaci-pdf && sed -i "s/DB_PASSWORD=/DB_PASSWORD=$DB_PASSWORD/" .env
6069
RUN cd hanaci-pdf && echo "TELEGRAM_BOT_ID=xxxx" >> .env
6170
RUN cd hanaci-pdf && echo "TELEGRAM_CHAT_ID=xxxx" >> .env
6271

63-
# Expose port 9000
64-
EXPOSE 9000
72+
# Configure nginx instances
73+
RUN mkdir /etc/nginx/sites-enabled
74+
COPY module/nginx/nginx.conf /etc/nginx/nginx.conf
75+
COPY module/nginx/sites-available/pdf-hanaci.conf /etc/nginx/sites-available/pdf-hanaci.conf
76+
RUN ln -s /etc/nginx/sites-available/pdf-hanaci.conf /etc/nginx/sites-enabled/
77+
78+
# Set up cron job for Laravel scheduler
79+
COPY module/hanaci/hanaci-pdf/pdf-cron /etc/crontabs/root
80+
RUN touch /var/log/cron.log && chmod 0644 /var/log/cron.log
81+
82+
# Configure supervisord
83+
COPY module/instance/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
84+
85+
# Expose necessary ports
86+
EXPOSE 81 9000
6587

66-
# Start PHP FPM
67-
CMD ["php-fpm"]
88+
# Start Nginx and PHP-FPM with supervisord
89+
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

Dockerfile/Dockerfile.hana-instance-services.sit

-39
This file was deleted.

docker-compose.yml

+31-34
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
services:
22
hana-app-pdf:
3-
image: nicklas373/hana-app-pdf-sit:1.4
3+
image: nicklas373/hana-app-pdf-sit:1.5
44
container_name: "hana-app-pdf"
55
cpus: 2.0
66
mem_limit: 512M
77
mem_reservation: 256M
88
restart: unless-stopped
99
working_dir: /var/www/html/hanaci-pdf
10+
ports:
11+
- "81:81"
1012
environment:
1113
- APP_NAME=pdf.hana-ci.com
1214
volumes:
@@ -15,15 +17,16 @@ services:
1517
- hana-network
1618
depends_on:
1719
- hana-api-services
18-
- hana-instance-services
1920
hana-api-services:
20-
image: nicklas373/hana-api-services-sit:1.6
21+
image: nicklas373/hana-api-services-sit:1.7
2122
container_name: "hana-api-services"
2223
cpus: 2.0
2324
mem_limit: 512M
2425
mem_reservation: 256M
2526
restart: always
2627
working_dir: /var/www/html/hanaci-api
28+
ports:
29+
- "80:80"
2730
environment:
2831
- APP_NAME=gw.hana-ci.com
2932
volumes:
@@ -32,7 +35,25 @@ services:
3235
- hana-network
3336
depends_on:
3437
- hana-db-services
35-
- hana-instance-services
38+
hana-minio:
39+
image: minio/minio:latest
40+
container_name: "hanaci-minio"
41+
cpus: 1.0
42+
mem_limit: 512M
43+
mem_reservation: 256M
44+
restart: unless-stopped
45+
ports:
46+
- "9000:9000"
47+
- "9001:9001"
48+
networks:
49+
- hana-network
50+
volumes:
51+
- minio-data:/data
52+
- minio-config:/root/.minio
53+
environment:
54+
MINIO_ROOT_USER: "eureka"
55+
MINIO_ROOT_PASSWORD: "eureka"
56+
command: server /data --console-address ":9001"
3657
hana-db-services:
3758
image: postgres:16.1
3859
container_name: "hana-db-services"
@@ -45,10 +66,10 @@ services:
4566
env_file:
4667
- .env
4768
environment:
48-
PGPASSWORD: "${DB_PASSWORD}"
49-
POSTGRES_DB: "${DB_DATABASE}"
50-
POSTGRES_USER: "${DB_USERNAME}"
51-
POSTGRES_PASSWORD: "${DB_PASSWORD}"
69+
PGPASSWORD: "postgres"
70+
POSTGRES_DB: "postgres"
71+
POSTGRES_USER: "master"
72+
POSTGRES_PASSWORD: "postgres"
5273
PGDATA: /var/lib/postgresql/data/pgdata
5374
volumes:
5475
- "hana-db-services:/var/lib/postgresql/data"
@@ -57,37 +78,13 @@ services:
5778
- hana-network
5879
depends_on:
5980
- hana-instance-services
60-
hana-instance-services:
61-
image: nicklas373/hana-instance-services-sit:1.3
62-
container_name: "hana-instance-services"
63-
cpus: 2.0
64-
mem_limit: 1G
65-
mem_reservation: 512M
66-
restart: always
67-
ports:
68-
- "80:80"
69-
- "81:81"
70-
volumes:
71-
- ./module/imagick/policy.xml:/etc/ImageMagick-6/policy.xml
72-
- ./module/nginx/nginx.conf:/etc/nginx/nginx.conf
73-
- ./module/nginx/sites-available/api-hanaci.conf:/etc/nginx/sites-available/api-hanaci.conf
74-
- ./module/nginx/sites-available/pdf-hanaci.conf:/etc/nginx/sites-available/pdf-hanaci.conf
75-
- ./module/php/php.ini:/etc/php/8.2/cli/conf.d/99-hana.ini
76-
- ./module/php/php.ini:/etc/php/8.2/fpm/conf.d/99-hana.ini
77-
- hana-app-pdf:/var/www/html/hanaci-pdf
78-
- hana-api-services:/var/www/html/hanaci-api
79-
- hana-instance-services:/var/log/supervisor
80-
networks:
81-
- hana-network
8281
networks:
8382
hana-network:
8483
driver: bridge
8584
volumes:
8685
hana-db-services:
8786
driver: local
88-
hana-app-pdf:
89-
driver: local
90-
hana-api-services:
87+
minio-data:
9188
driver: local
92-
hana-instance-services:
89+
minio-config:
9390
driver: local

module/instance/init-user-db.sh

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
set -e
33

44
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
5+
CREATE DATABASE hanaci_pdf;
56
CREATE USER eureka WITH PASSWORD 'eureka';
67
GRANT USAGE, CREATE ON SCHEMA public TO eureka;
78
ANAYLYZE;

module/instance/supervisord.conf

+6-20
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,18 @@
11
[supervisord]
22
nodaemon=true
33
user=root
4-
logfile=/var/log/supervisor/supervisord.log
5-
pidfile=/var/run/supervisord.pid
6-
7-
[program:cron]
8-
command=cron -f
9-
autostart=true
10-
autorestart=true
11-
stderr_logfile=/var/log/supervisor/%(program_name)s_stderr.log
12-
stderr_logfile_maxbytes=10MB
13-
stdout_logfile=/var/log/supervisor/%(program_name)s_stdout.log
14-
stdout_logfile_maxbytes=10MB
154

165
[program:nginx]
176
command=/usr/sbin/nginx -g "daemon off;"
187
autostart=true
198
autorestart=true
20-
stderr_logfile=/var/log/supervisor/%(program_name)s_stderr.log
21-
stderr_logfile_maxbytes=10MB
22-
stdout_logfile=/var/log/supervisor/%(program_name)s_stdout.log
23-
stdout_logfile_maxbytes=10MB
249

2510
[program:php-fpm]
26-
command=php-fpm8.2 --nodaemonize
11+
command=/usr/local/sbin/php-fpm --nodaemonize
12+
autostart=true
13+
autorestart=true
14+
15+
[program:cron]
16+
command=/usr/sbin/crond -f -l 2
2717
autostart=true
2818
autorestart=true
29-
stderr_logfile=/var/log/supervisor/%(program_name)s_stderr.log
30-
stderr_logfile_maxbytes=10MB
31-
stdout_logfile=/var/log/supervisor/%(program_name)s_stdout.log
32-
stdout_logfile_maxbytes=10MB

0 commit comments

Comments
 (0)