From 80e8d4d9461aaa646033ad5e65a4b7595c02635a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juho=20V=C3=A4h=C3=A4kangas?= Date: Thu, 8 Feb 2024 23:53:52 +0200 Subject: [PATCH 1/5] =?UTF-8?q?Dockerfile=20nginx:ll=C3=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-nginx/Dockerfile | 29 +++++++++++++++++++++++++++++ docker-nginx/entrypoint | 3 +++ docker-nginx/mlinvoice-nginx.conf | 28 ++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 docker-nginx/Dockerfile create mode 100644 docker-nginx/entrypoint create mode 100644 docker-nginx/mlinvoice-nginx.conf diff --git a/docker-nginx/Dockerfile b/docker-nginx/Dockerfile new file mode 100644 index 00000000..bb4f2168 --- /dev/null +++ b/docker-nginx/Dockerfile @@ -0,0 +1,29 @@ +FROM alpine:latest + +RUN apk update +RUN apk --no-cache add nginx php83-mbstring php83-fpm php83-mysqli php82-mysqlnd php83-session curl unzip + +WORKDIR /work + +RUN curl -O https://labs.fi/files/mlinvoice-2.1.2.zip +RUN unzip mlinvoice-2.1.2.zip +RUN rm mlinvoice-2.1.2.zip + +RUN sed -ri \ + -e "s/^user = nobody/user = www/" \ + -e "s/^group = nobody/group = www/" /etc/php83/php-fpm.d/www.conf + + +RUN addgroup -g 2024 www +RUN adduser -S -D www -G www + +RUN chown www:www /work/mlinvoice /work/mlinvoice/config.* + +COPY mlinvoice-nginx.conf /etc/nginx/nginx.conf +COPY entrypoint /work/entrypoint + +EXPOSE 80 + +HEALTHCHECK --interval=5m CMD curl -f http://localhost || exit 1 + +ENTRYPOINT ["sh", "/work/entrypoint"] diff --git a/docker-nginx/entrypoint b/docker-nginx/entrypoint new file mode 100644 index 00000000..c0921479 --- /dev/null +++ b/docker-nginx/entrypoint @@ -0,0 +1,3 @@ +#!/bin/sh +php-fpm83 & +nginx diff --git a/docker-nginx/mlinvoice-nginx.conf b/docker-nginx/mlinvoice-nginx.conf new file mode 100644 index 00000000..6bc94ea7 --- /dev/null +++ b/docker-nginx/mlinvoice-nginx.conf @@ -0,0 +1,28 @@ +user nobody; +worker_processes 2; +error_log /dev/stdout; + +events { + worker_connections 1024; +} +http { + default_type application/octet-sream; + include mime.types; + server_names_hash_bucket_size 128; + client_max_body_size 3M; + charset utf-8; + server { + listen 80; + root /work/mlinvoice; + location / { + index index.php index.html; + } + location ~ \.php$ { + include fastcgi_params; + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; + } + } +} +daemon off; From 0f7f8fdfb0149f219797588159103292272294e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juho=20V=C3=A4h=C3=A4kangas?= Date: Wed, 6 Nov 2024 17:14:34 +0200 Subject: [PATCH 2/5] Update Dockerfile --- docker-nginx/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-nginx/Dockerfile b/docker-nginx/Dockerfile index bb4f2168..5b0aa37e 100644 --- a/docker-nginx/Dockerfile +++ b/docker-nginx/Dockerfile @@ -19,11 +19,11 @@ RUN adduser -S -D www -G www RUN chown www:www /work/mlinvoice /work/mlinvoice/config.* +COPY config.php.sample /work/mlinvoice/config.php.sample COPY mlinvoice-nginx.conf /etc/nginx/nginx.conf COPY entrypoint /work/entrypoint EXPOSE 80 -HEALTHCHECK --interval=5m CMD curl -f http://localhost || exit 1 ENTRYPOINT ["sh", "/work/entrypoint"] From 06a5dc8dbdf2e52245effc8ec421925a82aecc9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juho=20V=C3=A4h=C3=A4kangas?= Date: Wed, 6 Nov 2024 17:17:08 +0200 Subject: [PATCH 3/5] Create config.php.sample --- docker-nginx/config.php.sample | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 docker-nginx/config.php.sample diff --git a/docker-nginx/config.php.sample b/docker-nginx/config.php.sample new file mode 100644 index 00000000..33487a74 --- /dev/null +++ b/docker-nginx/config.php.sample @@ -0,0 +1,19 @@ + Date: Wed, 6 Nov 2024 17:17:58 +0200 Subject: [PATCH 4/5] Create docker-compose.yml --- docker-nginx/docker-compose.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 docker-nginx/docker-compose.yml diff --git a/docker-nginx/docker-compose.yml b/docker-nginx/docker-compose.yml new file mode 100644 index 00000000..392218c0 --- /dev/null +++ b/docker-nginx/docker-compose.yml @@ -0,0 +1,19 @@ +services: + mlinvoice: + container_name: mlinvoice + build: . + ports: + - '8888:80' + db: + image: mysql:latest + restart: always + environment: + MYSQL_DATABASE: 'mlinvoice' + MYSQL_USER: 'mlinvoice' + MYSQL_PASSWORD: 'mlinvoice' + MYSQL_ROOT_PASSWORD: 'password' + volumes: + - my-db:/var/lib/mysql + - ./init-script.sql:/docker-entrypoint-initdb.d/init-script.sql +volumes: + my-db: From 3c2f5d85521fce6b5571103be56fa4753ad9c339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juho=20V=C3=A4h=C3=A4kangas?= Date: Wed, 6 Nov 2024 17:18:25 +0200 Subject: [PATCH 5/5] Create init-script.sql --- docker-nginx/init-script.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 docker-nginx/init-script.sql diff --git a/docker-nginx/init-script.sql b/docker-nginx/init-script.sql new file mode 100644 index 00000000..f7a2d6fb --- /dev/null +++ b/docker-nginx/init-script.sql @@ -0,0 +1,3 @@ +CREATE DATABASE iF NOT EXISTS mlinvoice; +GRANT ALL PRIVILEGES ON mlinvoice.* TO 'mlinvoice'@'%'; +ALTER USER 'mlinvoice' IDENTIFIED WITH mysql_native_password BY 'mlinvoice';