diff --git a/myvc-run.js b/myvc-run.js index 0ad19cb..d29cc4e 100644 --- a/myvc-run.js +++ b/myvc-run.js @@ -38,6 +38,9 @@ class Run { async run(myvc, opts) { const dumpDir = `${opts.myvcDir}/dump`; + const serverDir = path.join(__dirname, 'server'); + + // Fetch dump information if (!await fs.pathExists(`${dumpDir}/.dump.sql`)) throw new Error('To run local database you have to create a dump first'); @@ -68,13 +71,27 @@ class Run { } } - const dockerfilePath = path.join(__dirname, 'server', 'Dockerfile'); - + // Build base server image + + await docker.build(__dirname, { + tag: 'myvc/server-base', + file: path.join(serverDir, 'Dockerfile') + }, opts.debug); + + + // Build server image + + let serverDockerfile = path.join(dumpDir, 'Dockerfile'); + if (!await fs.pathExists(serverDockerfile)) + serverDockerfile = path.join(serverDir, 'Dockerfile.server'); + await docker.build(__dirname, { tag: 'myvc/server', - file: dockerfilePath + file: serverDockerfile }, opts.debug); + // Build dump image + const today = new Date(); const pad = v => v < 10 ? '0' + v : v; const year = today.getFullYear(); @@ -84,10 +101,12 @@ class Run { await docker.build(opts.myvcDir, { tag: opts.code, - file: `${dockerfilePath}.dump`, + file: path.join(serverDir, 'Dockerfile.dump'), buildArg: `STAMP=${stamp}` }, opts.debug); + // Run container + const isRandom = opts.random; const dbConfig = Object.assign({}, opts.dbConfig); diff --git a/package.json b/package.json index 4ab2f09..611f749 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "myvc", - "version": "1.4.9", + "version": "1.4.10", "author": "Verdnatura Levante SL", "description": "MySQL Version Control", "license": "GPL-3.0", diff --git a/server/Dockerfile b/server/Dockerfile index 190c838..43444a6 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -1,19 +1,11 @@ FROM mariadb:10.7.3 ENV MYSQL_ROOT_PASSWORD root -ENV TZ Europe/Madrid ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update \ && apt-get install -y --no-install-recommends \ curl \ - ca-certificates \ - tzdata \ - && curl -sL https://apt.verdnatura.es/conf/verdnatura.gpg | apt-key add - \ - && echo "deb http://apt.verdnatura.es/ jessie main" > /etc/apt/sources.list.d/vn.list \ - && apt-get update \ - && apt-get install -y \ - vn-mariadb \ && curl -sL https://deb.nodesource.com/setup_14.x | bash - \ && apt-get install -y --no-install-recommends \ nodejs \ @@ -51,7 +43,6 @@ COPY \ server/docker-start.sh \ /usr/local/bin/ -USER mysql ENTRYPOINT ["docker-start.sh"] CMD ["mysqld"] diff --git a/server/Dockerfile.server b/server/Dockerfile.server new file mode 100644 index 0000000..ca49422 --- /dev/null +++ b/server/Dockerfile.server @@ -0,0 +1,3 @@ +FROM myvc/server-base + +USER mysql diff --git a/template/package.json b/template/package.json index 92048f2..cb3d1c4 100644 --- a/template/package.json +++ b/template/package.json @@ -8,6 +8,6 @@ "type": "git" }, "dependencies": { - "myvc": "^1.4.9" + "myvc": "^1.4.10" } }