Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7bbd6bbcf1 | |||
| 7ddef6ed1b | |||
| 4581f0376a | |||
| da8bba93eb | |||
| ddc07e4605 | |||
| 29ca934b93 | |||
| 0dd1717ff6 | |||
| a23fb81570 | |||
| 83af2b1395 | |||
| b08e099b1e |
@@ -106,6 +106,5 @@ dist
|
||||
# Docker generated files and folders
|
||||
letsencrypt/
|
||||
mysql/
|
||||
Dockerfile
|
||||
docker-compose.yml
|
||||
startup.sql
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
|
||||
FROM node:15
|
||||
WORKDIR "/app"
|
||||
COPY package*.json ./
|
||||
RUN npm install --production
|
||||
COPY . /app
|
||||
EXPOSE 3200
|
||||
USER node
|
||||
ENTRYPOINT ["bash", "-c"]
|
||||
CMD ["sleep 10 && npm start"]
|
||||
@@ -4,9 +4,7 @@ An API centric auth server. Uses Sequelize and mariaDB by default.
|
||||
|
||||
# Setup
|
||||
|
||||
TODO: Dockerize this project
|
||||
|
||||
TODO: Write setup instructions, once dockerized
|
||||
There are multiple ways to run this app - it can run on it's own via `npm start` (for production) or `npm run dev` (for development). it can also run inside docker using `docker-compose up --build` - run `node configure-script.js` to generate docker-compose.yml.
|
||||
|
||||
# API
|
||||
|
||||
|
||||
+6
-5
@@ -54,7 +54,7 @@ const question = (prompt, def = null) => {
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
app:
|
||||
${appName}:
|
||||
build:
|
||||
context: .
|
||||
ports:
|
||||
@@ -98,7 +98,9 @@ services:
|
||||
- app-network
|
||||
volumes:
|
||||
- ./mysql:/var/lib/mysql
|
||||
traefik:
|
||||
- ./startup.sql:/docker-entrypoint-initdb.d/startup.sql:ro
|
||||
traefik_${appName}:
|
||||
container_name: ${appName}_traefik
|
||||
image: "traefik:v2.4"
|
||||
container_name: "traefik"
|
||||
command:
|
||||
@@ -116,7 +118,6 @@ services:
|
||||
volumes:
|
||||
- "./letsencrypt:/letsencrypt"
|
||||
- "/var/run/docker.sock:/var/run/docker.sock:ro"
|
||||
- "./startup.sql:/docker-entrypoint-initdb.d/startup.sql:ro"
|
||||
networks:
|
||||
- app-network
|
||||
networks:
|
||||
@@ -133,13 +134,13 @@ COPY . /app
|
||||
EXPOSE ${appPort}
|
||||
USER node
|
||||
ENTRYPOINT ["bash", "-c"]
|
||||
CMD ["sleep 10 && npm start"]
|
||||
CMD ["sleep 10 && npm start"]
|
||||
`;
|
||||
|
||||
const sqlfile = `
|
||||
CREATE DATABASE IF NOT EXISTS ${appName};
|
||||
CREATE USER IF NOT EXISTS '${appDBUser}'@'%' IDENTIFIED BY '${appDBPass}';
|
||||
GRANT ALL PRIVILEGES ON ${appName}.* TO '${appDBUser}'@'%';
|
||||
GRANT ALL PRIVILEGES ON ${appName}.* TO '${appDBUser}'@'%';
|
||||
`;
|
||||
|
||||
fs.writeFileSync('docker-compose.yml', ymlfile);
|
||||
|
||||
@@ -17,7 +17,7 @@ const route = async (req, res) => {
|
||||
|
||||
//compare the user's password
|
||||
const compare = utils.promisify(bcrypt.compare);
|
||||
const match = await compare(req.body.password, account.hash);
|
||||
const match = await compare(req.body.password || '', account.hash);
|
||||
|
||||
if (!match) {
|
||||
return res.status(401).send('incorrect password');
|
||||
|
||||
@@ -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: process.env.DB_LOGGING ? console.log : false
|
||||
});
|
||||
|
||||
sequelize.sync();
|
||||
|
||||
Reference in New Issue
Block a user