Tweaking deployment startup, read more
MariaDB's root password needs to be hidden from the game server's container, so I've changed the startup logic. MariaDB supposedly runs certain files that are found in a specific directory, so I'm using volumes to place startup.sql there. This needs testing on a mock deployment server. Related to #1
This commit is contained in:
+7
-9
@@ -59,7 +59,7 @@ const question = (prompt, def) => {
|
|||||||
|
|
||||||
//TODO: Implement chat-server as a docker container
|
//TODO: Implement chat-server as a docker container
|
||||||
|
|
||||||
const yml = `
|
const ymlfile = `
|
||||||
version: "3.6"
|
version: "3.6"
|
||||||
services:
|
services:
|
||||||
${projectName}:
|
${projectName}:
|
||||||
@@ -135,7 +135,8 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
MYSQL_ROOT_PASSWORD: ${databaseRootPassword}
|
MYSQL_ROOT_PASSWORD: ${databaseRootPassword}
|
||||||
volumes:
|
volumes:
|
||||||
- ./mysql:/var/lib/mysql
|
- "./mysql:/var/lib/mysql"
|
||||||
|
- "./startup.sql:/docker-entrypoint-initdb.d/startup.sql:ro"
|
||||||
networks:
|
networks:
|
||||||
- app-network
|
- app-network
|
||||||
|
|
||||||
@@ -171,16 +172,13 @@ FROM node:15
|
|||||||
WORKDIR "/app"
|
WORKDIR "/app"
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm install
|
RUN npm install
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get install -y mariadb-client
|
|
||||||
COPY . /app
|
COPY . /app
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
ENTRYPOINT ["bash", "-c"]
|
ENTRYPOINT ["bash", "-c"]
|
||||||
CMD ["mysql --host=database --user=root --password=${databaseRootPassword} < ./startup.sql && npm start"]
|
CMD ["npm start"]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const scriptfile = `
|
const sqlfile = `
|
||||||
CREATE DATABASE IF NOT EXISTS ${projectName};
|
CREATE DATABASE IF NOT EXISTS ${projectName};
|
||||||
CREATE USER IF NOT EXISTS '${projectDBUser}'@'%' IDENTIFIED BY '${projectDBPass}';
|
CREATE USER IF NOT EXISTS '${projectDBUser}'@'%' IDENTIFIED BY '${projectDBPass}';
|
||||||
GRANT ALL PRIVILEGES ON ${projectName}.* TO '${projectDBUser}'@'%';
|
GRANT ALL PRIVILEGES ON ${projectName}.* TO '${projectDBUser}'@'%';
|
||||||
@@ -196,9 +194,9 @@ GRANT ALL PRIVILEGES ON ${chatName}.* TO '${chatDBUser}'@'%';
|
|||||||
FLUSH PRIVILEGES;
|
FLUSH PRIVILEGES;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
fs.writeFileSync('docker-compose.yml', yml);
|
fs.writeFileSync('docker-compose.yml', ymlfile);
|
||||||
fs.writeFileSync('Dockerfile', dockerfile);
|
fs.writeFileSync('Dockerfile', dockerfile);
|
||||||
fs.writeFileSync('startup.sql', scriptfile);
|
fs.writeFileSync('startup.sql', sqlfile);
|
||||||
})()
|
})()
|
||||||
.then(() => rl.close())
|
.then(() => rl.close())
|
||||||
.catch(e => console.error(e))
|
.catch(e => console.error(e))
|
||||||
|
|||||||
Reference in New Issue
Block a user