Fixex the deployment issues, read more

The deployment issues were caused by sequelize running out-of-order.
I fixed this by placing sequelize.sync() in correct locations.

I've also updated news-server with these changes.

I've also removed mariadb stuff from the game server's Dockerfile.

Resolved #1
This commit is contained in:
2021-03-03 23:32:27 +00:00
parent b0ac371a43
commit 488f975e98
4 changed files with 14 additions and 7 deletions
+2 -2
View File
@@ -136,7 +136,7 @@ services:
MYSQL_ROOT_PASSWORD: ${databaseRootPassword}
volumes:
- "./mysql:/var/lib/mysql"
- "./startup.sql:/docker-entrypoint-initdb.d/startup.sql:ro"
- "./startup.sql:/docker-entrypoint-initdb.d/startup.sql:ro"
networks:
- app-network
@@ -175,7 +175,7 @@ RUN npm install
COPY . /app
EXPOSE 3000
ENTRYPOINT ["bash", "-c"]
CMD ["npm start"]
CMD ["sleep 10 && npm start"]
`;
const sqlfile = `
+3
View File
@@ -1,9 +1,12 @@
//DOCS: this whole file is just a big bugfix
//DOCS: ensure that there is at least one administration account
const bcrypt = require('bcryptjs');
const sequelize = require('../database');
const { accounts } = require('../database/models');
const defaultAdminAccount = async () => {
await sequelize.sync(); //this whole file is just one big BUGFIX
const admin = await accounts.findOne({
where: {
privilege: 'administrator'
+1 -1
View File
@@ -4,7 +4,7 @@ const sequelize = new Sequelize(process.env.DB_DATABASE, process.env.DB_USERNAME
host: process.env.DB_HOSTNAME,
dialect: 'mariadb',
timezone: process.env.DB_TIMEZONE,
logging: false
// logging: false
});
sequelize.sync();
+6 -2
View File
@@ -15,8 +15,8 @@ const SequelizeStore = require("connect-session-sequelize")(session.Store);
//database connection
const database = require('./database');
const models = require('./database/models'); //invoke all models
//setup the app middleware
app.use(formidable());
app.use(cookieParser());
app.use(session({
@@ -28,6 +28,9 @@ app.use(session({
})
}));
//invoke all models
const models = require('./database/models');
//account management
app.use('/api/accounts', require('./accounts'));
@@ -47,6 +50,7 @@ app.get('*', (req, res) => {
});
//startup
server.listen(process.env.WEB_PORT || 3000, (err) => {
server.listen(process.env.WEB_PORT || 3000, async (err) => {
await database.sync();
console.log(`listening to localhost:${process.env.WEB_PORT || 3000}`);
});