starting to create dockerfile for ci work
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
|||||||
|
FROM node:24-alpine
|
||||||
|
|
||||||
|
ENV DB_HOST=<your_db_host>
|
||||||
|
ENV DB_USERNAME=<your_db_username>
|
||||||
|
ENV DB_PASSWORD=<your_db_password>
|
||||||
|
ENV DB_PORT=<your_db_port>
|
||||||
|
ENV DB_DATABASE=<your_db_database>
|
||||||
|
|
||||||
|
ARG CMD
|
||||||
|
WORKDIR /app
|
||||||
|
COPY . .
|
||||||
|
RUN npm install --force
|
||||||
|
|
||||||
|
CMD ["node", "run", "$CMD"]
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
export default {
|
||||||
|
up: async (pool) => {
|
||||||
|
try {
|
||||||
|
await pool.query(
|
||||||
|
`
|
||||||
|
CREATE TABLE user (
|
||||||
|
id UUID PRIMARY KEY,
|
||||||
|
username TEXT UNIQUE NOT NULL,
|
||||||
|
password TEXT NOT NULL,
|
||||||
|
role_id UUID,
|
||||||
|
email TEXT UNIQUE NOT NULL,
|
||||||
|
createdAt TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updatedAt TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (role_id) REFERENCES role(id)
|
||||||
|
);
|
||||||
|
`
|
||||||
|
)
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error creating user table:', error)
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
},
|
||||||
|
down: async (pool) => {
|
||||||
|
try {
|
||||||
|
await pool.query(`
|
||||||
|
DROP TABLE user;
|
||||||
|
`)
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error dropping user table:', error)
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
export default {
|
||||||
|
up: async (pool) => {
|
||||||
|
try {
|
||||||
|
await pool.query(
|
||||||
|
`
|
||||||
|
CREATE TABLE role (
|
||||||
|
id UUID PRIMARY KEY,
|
||||||
|
name TEXT UNIQUE NOT NULL
|
||||||
|
);
|
||||||
|
`
|
||||||
|
)
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error creating role table:', error)
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
},
|
||||||
|
down: async (pool) => {
|
||||||
|
try {
|
||||||
|
await pool.query(`
|
||||||
|
DROP TABLE role;
|
||||||
|
`)
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error dropping role table:', error)
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
+7
-5
@@ -5,12 +5,14 @@ import path from 'path'
|
|||||||
const migrate = require('node-pg-migrate')
|
const migrate = require('node-pg-migrate')
|
||||||
|
|
||||||
// Database connection configuration
|
// Database connection configuration
|
||||||
|
const { DB_USERNAME, DB_HOST, DB_DATABASE, DB_PASSWORD, DB_PORT } = process.env;
|
||||||
|
|
||||||
const dbConfig = {
|
const dbConfig = {
|
||||||
user: 'your_user',
|
user: DB_USERNAME || 'your_user', // Use the environment variable if it exists, otherwise use 'your_user'
|
||||||
host: 'localhost',
|
host: DB_HOST || 'localhost',
|
||||||
database: 'your_database',
|
database: DB_DATABASE || 'your_database',
|
||||||
password: 'your_password',
|
password: DB_PASSWORD || 'your_password',
|
||||||
port: 5432,
|
port: parseInt(DB_PORT, 10) || 5432, // Convert the environment variable to a number if it exists, otherwise use 5432
|
||||||
}
|
}
|
||||||
|
|
||||||
const pool = new Pool(dbConfig)
|
const pool = new Pool(dbConfig)
|
||||||
|
|||||||
Reference in New Issue
Block a user