easypanel-io / templates

https://easypanel-templates.netlify.app/
129 stars 103 forks source link

add: Medusa #436

Open beakman opened 1 year ago

netlify[bot] commented 1 year ago

Deploy Preview for easypanel-templates ready!

Name Link
Latest commit 35279b4e66daa2362fee9451c24d70c0c8d8d1e1
Latest deploy log https://app.netlify.com/sites/easypanel-templates/deploys/659a5d07767c360008e83809
Deploy Preview https://deploy-preview-436--easypanel-templates.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

vinumweb commented 11 months ago

When is this ready?

beakman commented 10 months ago

Hello @vinumweb! I updated this template. Maybe you can checkout my branch and provide some feedback.

vinumweb commented 10 months ago

Hey @beakman can you add me on discord? I have some problems with the template. @vinumzz on discord

NoahPerez commented 10 months ago

I tried doesn't work for me also

vinumweb commented 10 months ago

Hey @NoahPerez. I got it working by using this guide: https://docs.medusajs.com/create-medusa-app. So you want to use the guide and do not use the nextjs built in storefront. Then you want to put the contents of the folder you just created with the guide on github. Then on easypanel, make a app service and put the details for the github repo with the medusa-create-app contents. The just deploy the app with the correct environment variables from the local project and you are good to go! Lmk. if you have any problems

NoahPerez commented 10 months ago

thanks for the quick reply @vinumweb

I'm not sure what you mean about "put the contents of the folder". I got the project locally without the front-end. I push the project to my GitHub and connect it to my repo in Easypanel . I choose Nixpacks for deployment and the .env in Easypanel

I'm missing something ?

DATABASE_TYPE=postgres DATABASE_URL= JWT_SECRET= COOKIE_SECRET= NODE_ENV=production

vinumweb commented 10 months ago

Hey @NoahPerez . So when locally following the tutorial linked, you should get a working medusa backend + admin dashboard that you can login to and create products on. All that code is in a folder that got created in the directory you choose when running the command. Put that directory on github and make a app service in easypanel ass you did. My env has this content:

DATABASE_TYPE=postgres DATABASE_URL=postgres://USERNAME:PASSWORD@URL/DBNAME MEDUSA_ADMIN_ONBOARDING_TYPE=default STORE_CORS=http://localhost:8000,http://localhost:7001 JWT_SECRET=somesecrethere COOKIE_SECRET=somesecrethere NODE_ENV=production NPM_CONFIG_PRODUCTION=false

Now in the domain tab you can just make a domain pointing to port 80 and go to that url and add /app at the end. Then you should have a working medusajs backend in easypanel.

NoahPerez commented 10 months ago

thanks again ! I'm getting this error, did you also got this error?

@vinumweb

`> cross-env medusa-admin build

╔════════════════════════════════════════════════════════════════════════╗ ║ ║ ║ Medusa collects anonymous usage analytics ║ ║ to help improve Medusa for all users. ║ ║ ║ ║ If you'd like to opt-out, you can use medusa telemetry --disable ║ ║ ║ ║ ║ ╚════════════════════════════════════════════════════════════════════════╝ {"level":"info","message":"Connection to Redis established","timestamp":"2024-01-25 14:22:40"} {"activity_id":"01HN0G0R6716JX7PKF340APWBQ","config":{},"level":"info","message":"Initializing models\n","timestamp":"2024-01-25 14:22:40"} {"activity_id":"01HN0G0R6716JX7PKF340APWBQ","duration":37,"level":"info","message":"Models initialized","timestamp":"2024-01-25 14:22:40"} {"activity_id":"01HN0G0R7DC6QMZCTBX32GPG80","config":{},"level":"info","message":"Initializing plugin models\n","timestamp":"2024-01-25 14:22:40"} {"activity_id":"01HN0G0R7DC6QMZCTBX32GPG80","duration":84,"level":"info","message":"Plugin models initialized","timestamp":"2024-01-25 14:22:40"} {"activity_id":"01HN0G0RA26Z4PHJM4G0X6HWFN","config":{},"level":"info","message":"Initializing strategies\n","timestamp":"2024-01-25 14:22:40"} {"activity_id":"01HN0G0RA26Z4PHJM4G0X6HWFN","duration":31,"level":"info","message":"Strategies initialized","timestamp":"2024-01-25 14:22:40"} {"activity_id":"01HN0G0RDKB7393RY75B33KYTJ","config":{},"level":"info","message":"Initializing database\n","timestamp":"2024-01-25 14:22:40"} {"level":"error","message":"Error starting server","stack":[{"columnNumber":15,"fileName":"/app/node_modules/@medusajs/utils/dist/common/handle-postgres-database-error.js","functionName":"handlePostgresDatabaseError","lineNumber":26,"methodName":null,"native":false,"typeName":null},{"columnNumber":5,"fileName":"node:internal/process/task_queues","functionName":"process.processTicksAndRejections","lineNumber":95,"methodName":"processTicksAndRejections","native":false,"typeName":"process"}],"timestamp":"2024-01-25 14:22:40"} npm WARN config production Use --omit=dev instead.

medusa-starter-default@0.0.1 start cross-env npm run build && medusa start

npm WARN config production Use --omit=dev instead.

medusa-starter-default@0.0.1 build cross-env npm run clean && npm run build:server && npm run build:admin

npm WARN config production Use --omit=dev instead.

medusa-starter-default@0.0.1 clean cross-env ./node_modules/.bin/rimraf dist

npm WARN config production Use --omit=dev instead.

medusa-starter-default@0.0.1 build:server cross-env npm run clean && tsc -p tsconfig.server.json

npm WARN config production Use --omit=dev instead.

medusa-starter-default@0.0.1 clean cross-env ./node_modules/.bin/rimraf dist

npm WARN config production Use --omit=dev instead.

medusa-starter-default@0.0.1 build:admin cross-env medusa-admin build`

vinumweb commented 10 months ago

@NoahPerez Try updating the package.json with this start script: "npm run build && medusa migrations run && medusa start" instead of "cross-env npm run clean && npm run build:server && npm run build:admin" Lmk. how it goes!

NoahPerez commented 10 months ago

thank you again! @vinumweb could you share your "scripts" ?

"scripts": { "start script": "npm run build && medusa migrations run && medusa start", "start": "cross-env npm run build && medusa start", "build": "cross-env npm run clean && npm run build:server && npm run build:admin", "clean": "cross-env ./node_modules/.bin/rimraf dist", "build:server": "cross-env npm run clean && tsc -p tsconfig.server.json", "build:admin": "cross-env medusa-admin build", "watch": "cross-env tsc --watch", "test": "cross-env jest", "seed": "cross-env medusa seed -f ./data/seed.json", "start:custom": "cross-env npm run build && node --preserve-symlinks --trace-warnings index.js", "dev": "cross-env npm run build:server && medusa develop" },

vinumweb commented 10 months ago

Of course @NoahPerez ! This is my scripts:

"scripts": { "clean": "cross-env ./node_modules/.bin/rimraf dist", "build": "cross-env npm run clean && npm run build:server && npm run build:admin", "build:server": "cross-env npm run clean && tsc -p tsconfig.server.json", "build:admin": "cross-env medusa-admin build", "watch": "cross-env tsc --watch", "test": "cross-env jest", "seed": "cross-env medusa seed -f ./data/seed.json", "start": "npm run build && medusa migrations run && medusa start", "start:custom": "cross-env npm run build && node --preserve-symlinks --trace-warnings index.js", "dev": "cross-env npm run build:server && medusa develop" },

NoahPerez commented 10 months ago

still getting the same error... did you make any changes in your medusa-config.js file please share @vinumweb

vinumweb commented 10 months ago

I think i did yes! This is the whole file:

const dotenv = require("dotenv");

let ENV_FILE_NAME = ""; switch (process.env.NODE_ENV) { case "production": ENV_FILE_NAME = ".env.production"; break; case "staging": ENV_FILE_NAME = ".env.staging"; break; case "test": ENV_FILE_NAME = ".env.test"; break; case "development": default: ENV_FILE_NAME = ".env"; break; }

try { dotenv.config({ path: process.cwd() + "/" + ENV_FILE_NAME }); } catch (e) {}

// CORS when consuming Medusa from admin const ADMIN_CORS = process.env.ADMIN_CORS || "http://localhost:7000,http://localhost:7001";

// CORS to avoid issues when consuming Medusa from a client const STORE_CORS = process.env.STORE_CORS || "http://localhost:3000";

const DATABASE_URL = process.env.DATABASE_URL || "postgres://localhost/medusa-starter-default";

const REDIS_URL = process.env.REDIS_URL || "redis://localhost:6379";

const plugins = [ medusa-fulfillment-manual, medusa-payment-manual, { resolve: @medusajs/file-local, options: { upload_dir: "uploads", }, }, { resolve: "@medusajs/admin", /* @type {import('@medusajs/admin').PluginOptions} / options: { autoRebuild: true, develop: { open: process.env.OPEN_BROWSER !== "false", }, }, }, ];

const modules = { /eventBus: { resolve: "@medusajs/event-bus-redis", options: { redisUrl: REDIS_URL } }, cacheService: { resolve: "@medusajs/cache-redis", options: { redisUrl: REDIS_URL } },/ };

/* @type {import('@medusajs/medusa').ConfigModule["projectConfig"]} / const projectConfig = { jwtSecret: process.env.JWT_SECRET, cookieSecret: process.env.COOKIE_SECRET, store_cors: STORE_CORS, database_url: DATABASE_URL, admin_cors: ADMIN_CORS, // Uncomment the following lines to enable REDIS // redis_url: REDIS_URL };

/* @type {import('@medusajs/medusa').ConfigModule} / module.exports = { projectConfig, plugins, modules, };

NoahPerez commented 10 months ago

thank you very much for your help @vinumweb at the end i found out i needed

"scripts": { "start script": "npm run build && medusa migrations run && medusa start", "start": "cross-env npm run build && medusa start", "build": "cross-env npm run clean && npm run build:server && npm run build:admin --omit=dev", this part also "clean": "cross-env ./node_modules/.bin/rimraf dist", "build:server": "cross-env npm run clean && tsc -p tsconfig.server.json", "build:admin": "cross-env medusa-admin build", "watch": "cross-env tsc --watch", "test": "cross-env jest", "seed": "cross-env medusa seed -f ./data/seed.json", "start:custom": "cross-env npm run build && node --preserve-symlinks --trace-warnings index.js", "dev": "cross-env npm run build:server && medusa develop" },

vinumweb commented 10 months ago

Ah okay! Does it work now? @NoahPerez

NoahPerez commented 10 months ago

yeah it working now @vinumweb

vinumweb commented 10 months ago

Nice. Glad you got it working! @NoahPerez

NoahPerez commented 8 months ago

@vinumweb Hello, lastest changes Easypanel i not able to add another medusa project, Are you u having the same issues ?

╔════════ Nixpacks v1.21.2 ═══════╗ ║ setup │ nodejs_18, npm-9_x ║ ║─────────────────────────────────║ ║ install │ npm i ║ ║─────────────────────────────────║ ║ build │ npm run build ║ ║─────────────────────────────────║ ║ start │ npm run start ║ ╚═════════════════════════════════╝

Saved output to: /etc/easypanel/projects/olga-shop-production/the-origin-shop-admin/code/

0 building with "default" instance using docker driver

1 [internal] load build definition from Dockerfile

1 ...

2 [internal] load .dockerignore

vinumweb commented 8 months ago

Hi @NoahPerez , I don't use Medusa anymore, so sadly I can't help you...

NoahPerez commented 8 months ago

@vinumweb no worries i just fix it , what are you working on ?