diff --git a/pica-environment/Dockerfile b/pica-environment/Dockerfile index d479c29..db0ca65 100644 --- a/pica-environment/Dockerfile +++ b/pica-environment/Dockerfile @@ -5,5 +5,6 @@ RUN \ apk add --no-cache \ fcgi \ fcgi++ \ + mariadb-connector-c \ && \ mkdir /run/pica diff --git a/pica-apache/README.md b/pica-maria-apache/README.md similarity index 100% rename from pica-apache/README.md rename to pica-maria-apache/README.md diff --git a/pica-apache/Dockerfile b/pica-maria-apache/apache/Dockerfile similarity index 100% rename from pica-apache/Dockerfile rename to pica-maria-apache/apache/Dockerfile diff --git a/pica-apache/vhost-pica.conf b/pica-maria-apache/apache/vhost-pica.conf similarity index 100% rename from pica-apache/vhost-pica.conf rename to pica-maria-apache/apache/vhost-pica.conf diff --git a/pica-apache/docker-compose.yml b/pica-maria-apache/docker-compose.yml similarity index 53% rename from pica-apache/docker-compose.yml rename to pica-maria-apache/docker-compose.yml index f7b1cac..dd9295f 100644 --- a/pica-apache/docker-compose.yml +++ b/pica-maria-apache/docker-compose.yml @@ -1,18 +1,25 @@ -version: "3" +version: "4" services: pica: image: thebluestbird/pica-standalone:latest volumes: - picarun:/run/pica + - mysqld:/run/mysqld + depends_on: + - maria apache: - build: . + build: ./apache image: thebluestbird/pica-apache:latest volumes: - picarun:/run/pica ports: - 8080:80 - links: - - pica + maria: + build: ./maria + image: thebluestbird/pica-maria:latest + volumes: + - mysqld:/run/mysqld volumes: picarun: + mysqld: diff --git a/pica-maria-apache/maria/Dockerfile b/pica-maria-apache/maria/Dockerfile new file mode 100644 index 0000000..c8f32d0 --- /dev/null +++ b/pica-maria-apache/maria/Dockerfile @@ -0,0 +1,19 @@ +# syntax=docker/dockerfile:1 +FROM alpine:latest +RUN \ + apk add --no-cache \ + mariadb \ + mariadb-client \ + && \ + mkdir -p /run/mysqld && \ + chown mysql:mysql /run/mysqld + +COPY my.cnf /etc/mysql/my.cnf +COPY createDB.sql /root/ +COPY createDB.sh /root/ + +RUN mysql_install_db && \ + chmod +x root/createDB.sh && \ + root/createDB.sh + +CMD ["mysqld", "--console"] diff --git a/pica-maria-apache/maria/createDB.sh b/pica-maria-apache/maria/createDB.sh new file mode 100644 index 0000000..ca68a75 --- /dev/null +++ b/pica-maria-apache/maria/createDB.sh @@ -0,0 +1,25 @@ +/usr/bin/mysqld_safe & + +# wait for it to start +echo -n "wait for db to start" + +c=1 +while [[ $c -le 10 ]] +do +echo 'SELECT 1' | /usr/bin/mysql &> /dev/null +# echo "R=$?" +if [ $? -eq 0 ]; then + break +fi +echo "." +sleep 1 +let c=c+1 +done +echo "C=$c" + +if [ $c -eq 11 ]; then +echo "database failed to start" +exit 1 +fi + +mysql < /root/createDB.sql diff --git a/pica-maria-apache/maria/createDB.sql b/pica-maria-apache/maria/createDB.sql new file mode 100644 index 0000000..3978cf1 --- /dev/null +++ b/pica-maria-apache/maria/createDB.sql @@ -0,0 +1,4 @@ +CREATE DATABASE IF NOT EXISTS pica; + +CREATE USER IF NOT EXISTS 'pica'@'localhost' IDENTIFIED BY 'pica'; +GRANT ALL PRIVILEGES ON pica.* TO 'pica'@'localhost'; diff --git a/pica-maria-apache/maria/my.cnf b/pica-maria-apache/maria/my.cnf new file mode 100644 index 0000000..ba3f218 --- /dev/null +++ b/pica-maria-apache/maria/my.cnf @@ -0,0 +1,30 @@ +[mysqld] +datadir=/var/lib/mysql +socket=/run/mysqld/mysqld.sock +user=mysql +# Disabling symbolic-links is recommended to prevent assorted security risks +symbolic-links=0 + +# Custom settings for performance and security +key_buffer_size=16M +max_allowed_packet=16M +thread_stack=192K +thread_cache_size=8 +query_cache_limit=1M +query_cache_size=16M + +# InnoDB settings +innodb_buffer_pool_size=128M +innodb_log_file_size=64M +innodb_flush_method=O_DIRECT +innodb_flush_log_at_trx_commit=2 + +# Character set and collation +character-set-server=utf8mb4 +collation-server=utf8mb4_unicode_ci + +[client] +default-character-set=utf8mb4 + +[mysql] +default-character-set=utf8mb4 diff --git a/pica-maria-apache/maria/vhost-pica.conf b/pica-maria-apache/maria/vhost-pica.conf new file mode 100644 index 0000000..75f1b94 --- /dev/null +++ b/pica-maria-apache/maria/vhost-pica.conf @@ -0,0 +1,9 @@ + + + Header set Access-Control-Allow-Origin "*" + Header set Access-Control-Allow-Headers: "*" + + + ProxyPass "unix:/run/pica/pica.sock|fcgi://localhost" + ProxyPassReverse "http://localhost" + diff --git a/pica-standalone/Dockerfile b/pica-standalone/Dockerfile index d794439..c1380df 100644 --- a/pica-standalone/Dockerfile +++ b/pica-standalone/Dockerfile @@ -9,18 +9,17 @@ RUN \ fcgi-dev \ cmake \ make \ - curl \ - && \ - mkdir build && \ - cd /build && \ - curl -o pica.tar.gz https://git.macaw.me/blue/pica/archive/main.tar.gz && \ - tar -xvzf pica.tar.gz && \ - cd pica && \ - mkdir build && \ - cd build && \ - cmake .. && \ - cmake --build . + mariadb-connector-c-dev + +ADD https://git.macaw.me/blue/pica/archive/main.tar.gz pica/ +WORKDIR pica +RUN tar -xvzf main.tar.gz && \ + cd pica && \ + mkdir build && \ + cd build && \ + cmake .. && \ + cmake --build . FROM thebluestbird/pica-environment:latest -COPY --from=0 /build/pica/build/pica /usr/bin/ +COPY --from=0 /pica/pica/build/pica /usr/bin/ CMD ["/usr/bin/pica"]