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: { params: {
ci: 'Workaround for continuous integration system', ci: 'Workaround for continuous integration system',
network: 'Docker network to attach container to', 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: { alias: {
ci: 'c', ci: 'c',
network: 'n', network: 'n',
random: 'r' random: 'r',
tmpfs: 'r'
}, },
boolean: [ boolean: [
'ci', 'ci',
@ -107,12 +109,11 @@ class Run extends Command {
} }
if (opts.network) if (opts.network)
Object.assign(runOptions, {network: opts.network}); runOptions.network = opts.network;
if (opts.tmpfs)
const runChown = process.platform != 'linux'; runOptions.tmpfs = '/var/lib/mysql';
Object.assign(runOptions, null, { Object.assign(runOptions, null, {
env: `RUN_CHOWN=${runChown}`,
detach: true detach: true
}); });
const ct = await docker.run(opts.code, null, runOptions); const ct = await docker.run(opts.code, null, runOptions);

4
package-lock.json generated
View File

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

View File

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

View File

@ -1,15 +1,14 @@
FROM myt/server FROM myt/server
USER root WORKDIR /workspace
COPY .dump dump/.dump COPY .dump dump/.dump
COPY dump.*.sql 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." \ RUN echo "[LOG] Import finished." \
&& rm -rf /workspace && rm -rf dump
COPY fixtures.*.sql dump/ COPY fixtures.*.sql dump/
USER mysql

View File

@ -1,13 +1,7 @@
FROM myt/base FROM myt/base
USER root
ENV MYSQL_ROOT_PASSWORD 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.cnf /etc/mysql/conf.d/
COPY \ COPY \
docker-init.sh \ docker-init.sh \
@ -15,10 +9,7 @@ COPY \
docker-start.sh \ docker-start.sh \
/usr/local/bin/ /usr/local/bin/
USER mysql
ENTRYPOINT ["docker-start.sh"] ENTRYPOINT ["docker-start.sh"]
CMD ["mysqld"] CMD ["mysqld"]
HEALTHCHECK --interval=2s --timeout=10s --retries=200 \ HEALTHCHECK --interval=2s --timeout=10s --retries=200 \

View File

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

View File

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

View File

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