pica now has mariadb client in environment, and a composition with mariadb to run it

This commit is contained in:
Blue 2023-12-07 19:15:27 -03:00
parent 7a54d5025f
commit d516963219
Signed by: blue
GPG Key ID: 9B203B252A63EE38
11 changed files with 110 additions and 16 deletions

View File

@ -5,5 +5,6 @@ RUN \
apk add --no-cache \
fcgi \
fcgi++ \
mariadb-connector-c \
&& \
mkdir /run/pica

View File

@ -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:

View File

@ -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"]

View File

@ -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

View File

@ -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';

View File

@ -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

View File

@ -0,0 +1,9 @@
<Location /pica>
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers: "*"
</IfModule>
ProxyPass "unix:/run/pica/pica.sock|fcgi://localhost"
ProxyPassReverse "http://localhost"
</Location>

View File

@ -9,12 +9,11 @@ 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 && \
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 && \
@ -22,5 +21,5 @@ RUN \
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"]