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:
+2
-2
@@ -136,7 +136,7 @@ services:
|
|||||||
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"
|
- "./startup.sql:/docker-entrypoint-initdb.d/startup.sql:ro"
|
||||||
networks:
|
networks:
|
||||||
- app-network
|
- app-network
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ RUN npm install
|
|||||||
COPY . /app
|
COPY . /app
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
ENTRYPOINT ["bash", "-c"]
|
ENTRYPOINT ["bash", "-c"]
|
||||||
CMD ["npm start"]
|
CMD ["sleep 10 && npm start"]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const sqlfile = `
|
const sqlfile = `
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
//DOCS: this whole file is just a big bugfix
|
//DOCS: this whole file is just a big bugfix
|
||||||
//DOCS: ensure that there is at least one administration account
|
//DOCS: ensure that there is at least one administration account
|
||||||
const bcrypt = require('bcryptjs');
|
const bcrypt = require('bcryptjs');
|
||||||
|
const sequelize = require('../database');
|
||||||
const { accounts } = require('../database/models');
|
const { accounts } = require('../database/models');
|
||||||
|
|
||||||
const defaultAdminAccount = async () => {
|
const defaultAdminAccount = async () => {
|
||||||
|
await sequelize.sync(); //this whole file is just one big BUGFIX
|
||||||
|
|
||||||
const admin = await accounts.findOne({
|
const admin = await accounts.findOne({
|
||||||
where: {
|
where: {
|
||||||
privilege: 'administrator'
|
privilege: 'administrator'
|
||||||
@@ -22,4 +25,4 @@ const defaultAdminAccount = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = defaultAdminAccount;
|
module.exports = defaultAdminAccount;
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ const sequelize = new Sequelize(process.env.DB_DATABASE, process.env.DB_USERNAME
|
|||||||
host: process.env.DB_HOSTNAME,
|
host: process.env.DB_HOSTNAME,
|
||||||
dialect: 'mariadb',
|
dialect: 'mariadb',
|
||||||
timezone: process.env.DB_TIMEZONE,
|
timezone: process.env.DB_TIMEZONE,
|
||||||
logging: false
|
// logging: false
|
||||||
});
|
});
|
||||||
|
|
||||||
sequelize.sync();
|
sequelize.sync();
|
||||||
|
|
||||||
module.exports = sequelize;
|
module.exports = sequelize;
|
||||||
|
|||||||
+6
-2
@@ -15,8 +15,8 @@ const SequelizeStore = require("connect-session-sequelize")(session.Store);
|
|||||||
|
|
||||||
//database connection
|
//database connection
|
||||||
const database = require('./database');
|
const database = require('./database');
|
||||||
const models = require('./database/models'); //invoke all models
|
|
||||||
|
|
||||||
|
//setup the app middleware
|
||||||
app.use(formidable());
|
app.use(formidable());
|
||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
app.use(session({
|
app.use(session({
|
||||||
@@ -28,6 +28,9 @@ app.use(session({
|
|||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
//invoke all models
|
||||||
|
const models = require('./database/models');
|
||||||
|
|
||||||
//account management
|
//account management
|
||||||
app.use('/api/accounts', require('./accounts'));
|
app.use('/api/accounts', require('./accounts'));
|
||||||
|
|
||||||
@@ -47,6 +50,7 @@ app.get('*', (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//startup
|
//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}`);
|
console.log(`listening to localhost:${process.env.WEB_PORT || 3000}`);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user