feat: refs #5483 tmpfs parameter added to run command

This commit is contained in:
Juan Ferrer 2024-01-29 19:45:19 +01:00
parent c893a473ed
commit f7821d0a18
8 changed files with 26 additions and 33 deletions

View File

@ -19,7 +19,8 @@ class Run extends Command {
params: {
ci: 'Workaround for continuous integration system',
network: 'Docker network to attach container to',
random: 'Whether to use a random container name and port'
random: 'Whether to use a random container name and port',
tmpfs: 'Whether to use tmpfs mount for MySQL data'
}
};
@ -27,7 +28,8 @@ class Run extends Command {
alias: {
ci: 'c',
network: 'n',
random: 'r'
random: 'r',
tmpfs: 'r'
},
boolean: [
'ci',
@ -107,12 +109,11 @@ class Run extends Command {
}
if (opts.network)
Object.assign(runOptions, {network: opts.network});
const runChown = process.platform != 'linux';
runOptions.network = opts.network;
if (opts.tmpfs)
runOptions.tmpfs = '/var/lib/mysql';
Object.assign(runOptions, null, {
env: `RUN_CHOWN=${runChown}`,
detach: true
});
const ct = await docker.run(opts.code, null, runOptions);

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@verdnatura/myt",
"version": "1.5.35",
"version": "1.6.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@verdnatura/myt",
"version": "1.5.35",
"version": "1.6.1",
"license": "GPL-3.0",
"dependencies": {
"@sqltools/formatter": "^1.2.5",

View File

@ -1,6 +1,6 @@
{
"name": "@verdnatura/myt",
"version": "1.6.0",
"version": "1.6.1",
"author": "Verdnatura Levante SL",
"description": "MySQL version control",
"license": "GPL-3.0",

View File

@ -1,15 +1,14 @@
FROM myt/server
USER root
WORKDIR /workspace
COPY .dump dump/.dump
COPY dump.*.sql dump/
RUN gosu mysql docker-init.sh
RUN mkdir -p /mysql-template \
&& chown mysql:mysql /mysql-template \
&& gosu mysql docker-init.sh
RUN echo "[LOG] Import finished." \
&& rm -rf /workspace
&& rm -rf dump
COPY fixtures.*.sql dump/
USER mysql

View File

@ -1,13 +1,7 @@
FROM myt/base
USER root
ENV MYSQL_ROOT_PASSWORD root
RUN mkdir /mysql-data \
&& chown -R mysql:mysql /mysql-data
WORKDIR /workspace
COPY docker.cnf /etc/mysql/conf.d/
COPY \
docker-init.sh \
@ -15,10 +9,7 @@ COPY \
docker-start.sh \
/usr/local/bin/
USER mysql
ENTRYPOINT ["docker-start.sh"]
CMD ["mysqld"]
HEALTHCHECK --interval=2s --timeout=10s --retries=200 \

View File

@ -1,15 +1,16 @@
#!/bin/bash
set -e
. /usr/local/bin/docker-entrypoint.sh
CMD=mysqld
ARGS=(mysqld --datadir=/mysql-template)
mysql_check_config "$CMD"
docker_setup_env "$CMD"
mysql_check_config ${ARGS[@]}
docker_setup_env ${ARGS[@]}
docker_create_db_directories
docker_verify_minimum_env
docker_init_database_dir "$CMD"
docker_temp_server_start "$CMD"
docker_init_database_dir ${ARGS[@]}
docker_temp_server_start ${ARGS[@]}
docker_setup_db
docker_process_init_files /docker-entrypoint-initdb.d/*

View File

@ -1,10 +1,12 @@
#!/bin/bash
set -e
# XXX: Workaround to avoid OverlayFS bug on MacOs
# https://docs.docker.com/storage/storagedriver/overlayfs-driver/#limitations-on-overlayfs-compatibility
if [ "$RUN_CHOWN" = "true" ]; then
chown -R mysql:mysql /mysql-data
if [ ! -d /var/lib/mysql/mysql ]; then
chown mysql:mysql /var/lib/mysql
cp -a /mysql-template/. /var/lib/mysql
fi
exec "$@"
exec gosu mysql "$@"

View File

@ -3,7 +3,6 @@ innodb_log_file_size = 4M
innodb_autoextend_increment = 4
innodb_page_size = 16K
log_bin_trust_function_creators = ON
datadir = /mysql-data
sql_mode = NO_ENGINE_SUBSTITUTION
table_definition_cache = 1024
skip-log-bin