Open predaytor opened 2 days ago
Also, after converting the config to the ES module, it doesn't seem to work in production (e.g. npx medusa db:migrate
). Running locally works fine. It would be nice to have more info on how to properly bundle an app with Docker.
Error in loading config: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
before:
const { loadEnv, defineConfig, Modules } = require("@medusajs/utils");
loadEnv(process.env.NODE_ENV, process.cwd());
const config = defineConfig({
projectConfig: {
// ...
},
// ...
});
module.exports = config;
after:
import { loadEnv, defineConfig, Modules } from "@medusajs/utils";
loadEnv(process.env.NODE_ENV, process.cwd());
const config = defineConfig({
projectConfig: {
// ...
},
// ...
});
export default config;
Hey, it seems you are not copying the dist
folder in the following copy commands.
COPY --from=builder /usr/src/app/package.json ./package.json
COPY --from=builder /usr/src/app/node_modules ./node_modules
COPY --from=builder /usr/src/app/build ./build
@thetutlage yeah, for some reason it wasn't generated with the /build
folder, not sure why. Medusa 1.0 and the running locally Medusa 2.0 build script work fine. Maybe something wrong with default typescript configuration?
It seems to work using similar setup for scripts from Medusa 1.0.
"scripts": {
"clean": "cross-env ./node_modules/.bin/rimraf dist",
"build": "cross-env npm run clean && medusa build && tsc -p tsconfig.json",
}
But without copying the ./src
folder to the docker image, the API routes don't work:
Cannot GET /store/custom
Maybe we should do like this?
COPY --from=builder /usr/src/app/dist ./src
Bug report
Describe the bug
I'm deploying fly.io using a docker build, compared to version 1.0 there are a few issues with the same production image. The API routes don't work unless the
/src
folder is commited on the production server (these are typescript files, not sure why that seems necessary).After running
medusa build
only the/build
folder is created,/dist
is missing for some reason. Running locally the build script outputs the/dist
folder, so not sure about that behavior.Also, in the latest medusa release,
x-publishable-api-key
seems to have no effect if we commit the/src
folder to access API routes.System information
Medusa version (including plugins): v2.0.9-preview Node.js version: 22 Database: Postgres (sslmode disable) Operating system: Linux Browser (if relevant): Chrome
Screenshots
Code snippets
Dockerfile
:fixed
Dockerfile
last stage: