Hey all, im trying to deploy an api with typeorm then run my migrations, but i dont understand how to do that
Dockerfile:
FROM node:lts-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install\
&& npm install typescript -g
COPY . .
RUN npm run tsc
EXPOSE 3000
#here im trying the migrations that im already generated
CMD [“npm”, “run”, “migration:run”]ENTRYPOINT [ “npm”, “start” ]
fly.toml:
app = “api”
kill_signal = “SIGINT”
kill_timeout = 5
processes =[env]
HOST = “db.internal”
DBPORT = “5432”
USERNAME = “postgres”
PASSWORD = “password”
DB = “db”[experimental]
allowed_public_ports =
auto_rollback = true[[services]]
http_checks =
internal_port = 8080
processes = [“app”]
protocol = “tcp”
script_checks =
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = “connections”[[services.ports]]
force_https = true
handlers = [“http”]
port = 80[[services.ports]]
handlers = [“tls”, “http”]
port = 443[[services.tcp_checks]]
grace_period = “1s”
interval = “15s”
restart_limit = 0
timeout = “2s”
scripts from package.json:
“scripts”: {
“tsc”: “tsc”,
“start”: “node ./build/Server.js”,
“migration:generate”: “typeorm-ts-node-commonjs -d ./src/DataSource.ts migration:generate ./src/migrations/default”,
“migration:run”: “typeorm-ts-node-commonjs -d ./src/DataSource.ts migration:run”,
“test”: “echo "Error: no test specified" && exit 1”
},
in my code i have this:
export default new DataSource({
type: ‘postgres’,
host: process.env.HOST,
port: parseInt(process.env.DBPORT || “5432”),
username: process.env.USERNAME,
password: process.env.PASSWORD,
database: process.env.DB,
entities: [${__dirname}/**/entities/*{ts,js}
],
migrations: [${__dirname}/**/migrations/*{ts,js}
],
});
What am i missing ?