#4036 Dump command improved
This commit is contained in:
parent
bfa522afbe
commit
a0ebfcf3f5
27
myvc-run.js
27
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);
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
FROM myvc/server-base
|
||||
|
||||
USER mysql
|
|
@ -8,6 +8,6 @@
|
|||
"type": "git"
|
||||
},
|
||||
"dependencies": {
|
||||
"myvc": "^1.4.9"
|
||||
"myvc": "^1.4.10"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue