thedevs-network / kutt

Free Modern URL Shortener.
https://kutt.it
MIT License
8.35k stars 1.08k forks source link

Docker Image won't run #729

Open davidgs opened 8 months ago

davidgs commented 8 months ago

Donwloaded the latest docker-compose.yml and tried to run it.

Linux 5.15.0-91-generic #101-Ubuntu SMP Tue Nov 14 13:30:08 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

At which point:

kutt_1      |
kutt_1      | > kutt@2.7.4 start /usr/src/app
kutt_1      | > npm run migrate && cross-env NODE_ENV=production node production-server/server.js
kutt_1      |
kutt_1      |
kutt_1      | > kutt@2.7.4 migrate /usr/src/app
kutt_1      | > knex migrate:latest --env production
kutt_1      |
kutt_1      | Requiring external module ts-node/register
kutt_1      | Using environment: production
kutt_1      | Error: The server does not support SSL connections
kutt_1      |     at Socket.<anonymous> (/usr/src/app/node_modules/pg/lib/connection.js:76:35)
kutt_1      |     at Object.onceWrapper (events.js:421:26)
kutt_1      |     at Socket.emit (events.js:314:20)
kutt_1      |     at Socket.EventEmitter.emit (domain.js:483:12)
kutt_1      |     at addChunk (_stream_readable.js:297:12)
kutt_1      |     at readableAddChunk (_stream_readable.js:272:9)
kutt_1      |     at Socket.Readable.push (_stream_readable.js:213:10)
kutt_1      |     at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
kutt_1      | npm ERR! code ELIFECYCLE
kutt_1      | npm ERR! errno 1
kutt_1      | npm ERR! kutt@2.7.4 migrate: `knex migrate:latest --env production`
kutt_1      | npm ERR! Exit status 1
kutt_1      | npm ERR!
kutt_1      | npm ERR! Failed at the kutt@2.7.4 migrate script.
kutt_1      | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
kutt_1      |
kutt_1      | npm ERR! A complete log of this run can be found in:
kutt_1      | npm ERR!     /root/.npm/_logs/2024-01-01T16_06_43_420Z-debug.log
kutt_1      | npm ERR! code ELIFECYCLE
kutt_1      | npm ERR! errno 1
kutt_1      | npm ERR! kutt@2.7.4 start: `npm run migrate && cross-env NODE_ENV=production node production-server/server.js`
kutt_1      | npm ERR! Exit status 1
kutt_1      | npm ERR!
kutt_1      | npm ERR! Failed at the kutt@2.7.4 start script.
kutt_1      | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
kutt_1      |
kutt_1      | npm ERR! A complete log of this run can be found in:
kutt_1      | npm ERR!     /root/.npm/_logs/2024-01-01T16_06_43_458Z-debug.log
kutt_kutt_1 exited with code 1

Which is the same error I get if I try to just run it locally, without Docker:

/srv/kutt # npm run start dev

> kutt@2.7.4 start
> npm run migrate && cross-env NODE_ENV=production node production-server/server.js dev

> kutt@2.7.4 migrate
> knex migrate:latest --env production

Requiring external module ts-node/register
Unknown file extension ".ts" for /srv/kutt/knexfile.ts
TypeError: Unknown file extension ".ts" for /srv/kutt/knexfile.ts
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:203:36)
    at defaultLoad (node:internal/modules/esm/load:143:22)
    at async ModuleLoader.load (node:internal/modules/esm/loader:409:7)
    at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:291:45)
    at async link (node:internal/modules/esm/module_job:76:21)

So it appears as though things are hopelessly broken.

kengher commented 6 months ago

is your PostgreSQL server configured to accept SSL?

As for the second error, do you have the file 'tsconfig.json' in the root folder? If not, create one with:

{
    "compilerOptions": {
        "target": "es2018",
        "module": "commonjs",
        "sourceMap": true,
        "outDir": "production-server",
        "noUnusedLocals": true,
        "resolveJsonModule": true,
        "esModuleInterop": true,
        "noEmit": false,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "strict": false
    },
    "include": [
        "global.d.ts",
        "server"
    ]
}

then

npm run build
npm run dev