exoframejs / exoframe

Exoframe is a self-hosted tool that allows simple one-command deployments using Docker
https://exoframejs.github.io/exoframe/
1.13k stars 56 forks source link

NodeJS Deployment Fail #279

Closed niklasgrewe closed 4 years ago

niklasgrewe commented 4 years ago

Hey everyone thank you very much for this piece of software - very cool and useful

i am using the latest stable version of exoframe client and server.

my server.config.yml file looks like this:

debug: true
letsencrypt: true
letsencryptEmail: niklas@grewe.io
compress: true
baseDomain: false
cors: false
traefikImage: 'traefik:latest'
traefikName: 'exoframe-traefik'
traefikArgs: []
exoframeNetwork: 'exoframe'
updateChannel: 'stable'
publicKeysPath: '/my/path/'
swarm: false
plugins:
   install: ['exoframe-plugin-swarm']
   swarm:
     enabled: false

my exoframe.json file inside my sapper project looks like this:

{
    "name": "Website",
    "restart": "always",
    "domain": "grewe.io",
    "letsencrypt": true
}

Note: The deployment will also not working, when i remove the config file


When i run exoframe -vvv in my sapper project i will get this result:

No .exoframeignore file found, using default ignores

Ignoring following paths: [ '.git', 'node_modules', '.exoframeignore' ]
[info] Deploying Node.js project..
[verbose] Building image with tag: exo-niklas-website:latest
[verbose] Step 1/10 : FROM node:latest
[verbose] 

[verbose] {"status":"Pulling from library/node","id":"latest"}
[verbose] {"status":"Digest: sha256:c45a2f94b63b49b50fee7b4a4a240830a367f36d8bc8e9069a712822b4f4f85e"}
[verbose] {"status":"Status: Image is up to date for node:latest"}
[verbose]  ---> e0e011be5f0f

[verbose] Step 2/10 : RUN mkdir -p /usr/src/app
[verbose] 

[verbose]  ---> Using cache

[verbose]  ---> a67289662ea5

[verbose] Step 3/10 : WORKDIR /usr/src/app
[verbose] 

[verbose]  ---> Using cache

[verbose]  ---> d24877da23aa

[verbose] Step 4/10 : COPY package.json /usr/src/app/
[verbose] 

[verbose]  ---> Using cache

[verbose]  ---> b205a1dd6932

[verbose] Step 5/10 : COPY package-lock.json /usr/src/app/
[verbose] 

[verbose]  ---> Using cache

[verbose]  ---> a61f2b48ff42

[verbose] Step 6/10 : RUN npm ci --silent
[verbose] 

[verbose]  ---> Using cache

[verbose]  ---> 0414099d975a

[verbose] Step 7/10 : COPY . /usr/src/app
[verbose] 

[verbose]  ---> fbf8f3b3009a

[verbose] Step 8/10 : RUN npm run build --if-present
[verbose] 

[verbose]  ---> Running in ba80efd5df80

[verbose] 
> grewe.io@0.0.1 build /usr/src/app
> npm run build:tailwind && sapper build

[verbose] 
> grewe.io@0.0.1 build:tailwind /usr/src/app
> NODE_ENV=production postcss static/tailwind.css -o static/index.css

[verbose] > Building...

[verbose] 

[verbose] ┌──────────────┐
│ built client │
└──────────────┘

[verbose]      765 B about.84544a3b.js
           └ src/routes/about.svelte
   1.71 kB index.543aab56.js
           └ src/routes/blog/index.svelte
   1.12 kB [slug].fe0ace99.js
           └ src/routes/blog/[slug].svelte
      30 B client.86edaab2.js
   23.8 kB client.608fbb87.js
           │ node_modules/svelte/internal/index.mjs (34.6%)
           │ src/node_modules/@sapper/app.mjs (20.8%)
           │ src/node_modules/@sapper/internal/App.svelte (12.6%)
           │ src/components/partials/Logo.svelte (8.5%)
           │ src/components/partials/Navbar.svelte (6.7%)
           │ src/routes/_error.svelte (6.2%)
           │ src/routes/_layout.svelte (4.1%)
           │ node_modules/svelte/store/index.mjs (2.9%)
           │ src/components/partials/Footer.svelte (1.8%)
           │ src/node_modules/@sapper/internal/manifest-client.mjs (1.7%)
           │ src/client.js (0.1%)
           └ src/node_modules/@sapper/internal/shared.mjs (0.1%)
   40.5 kB index.80e76067.js
           │ src/routes/index.svelte (44.5%)
           │ src/components/partials/BottomSheet.svelte (15.4%)
           │ src/components/partials/Modal.svelte (14.3%)
           │ src/components/partials/Dialog.svelte (9.7%)
           │ src/components/partials/Banner.svelte (7.7%)
           │ src/components/partials/Button.svelte (7.0%)
           │ node_modules/svelte/transition/index.mjs (1.4%)
           └ node_modules/svelte/easing/index.mjs (0.1%)

[verbose] 

[verbose] ┌──────────────┐
│ built server │
└──────────────┘
    162 kB server.js
           │ src/node_modules/@sapper/server.mjs (60.7%)
           │ src/routes/index.svelte (15.3%)
           │ src/components/partials/Modal.svelte (4.4%)
           │ src/routes/blog/_posts.js (3.1%)
           │ src/components/partials/Banner.svelte (2.3%)
           │ node_modules/svelte/internal/index.mjs (2.3%)
           │ src/routes/blog/[slug].svelte (2.2%)
           │ src/routes/_error.svelte (1.2%)
           │ src/routes/blog/index.svelte (1.2%)
           │ node_modules/svelte/store/index.mjs (1.0%)
           │ src/node_modules/@sapper/internal/App.svelte (0.9%)
           │ src/components/partials/Logo.svelte (0.8%)
           │ src/components/partials/Button.svelte (0.8%)
           │ src/components/partials/Dialog.svelte (0.8%)
           │ src/node_modules/@sapper/internal/manifest-server.mjs (0.7%)
           │ src/routes/_layout.svelte (0.7%)
           │ src/components/partials/Navbar.svelte (0.6%)
           │ src/routes/blog/[slug].json.js (0.3%)
           │ src/routes/about.svelte (0.2%)
           │ src/components/partials/Footer.svelte (0.2%)
           │ src/server.js (0.2%)
           │ src/routes/blog/index.json.js (0.1%)
           └ src/node_modules/@sapper/internal/shared.mjs (0.0%)

[verbose] 
┌─────────────────────┐
│ built serviceworker │
└─────────────────────┘
   2.33 kB service-worker.js
           │ src/service-worker.js (58.3%)
           └ src/node_modules/@sapper/service-worker.js (41.7%)

[verbose] 
> Finished in 5.8s. Type node __sapper__/build to run the app.

[verbose] Removing intermediate container ba80efd5df80

[verbose]  ---> fccc93a76bb7

[verbose] Step 9/10 : EXPOSE 80
[verbose] 

[verbose]  ---> Running in 18b71364925d

[verbose] Removing intermediate container 18b71364925d

[verbose]  ---> 57f884dcb564

[verbose] Step 10/10 : CMD ["npm", "start"]
[verbose] 

[verbose]  ---> Running in e4d6ccd445be

[verbose] Removing intermediate container e4d6ccd445be

[verbose]  ---> bfe5e82e1626

[verbose] {"aux":{"ID":"sha256:bfe5e82e16265a182a7b34f6f9d4ff2ba59f49c06e896fc2f83110bda069d7e9"}}
[verbose] Successfully built bfe5e82e1626

[verbose] Successfully tagged exo-niklas-website:latest

[error] undefined
{
  "level": "error"
}
Error deploying project: Error
Build log:

No log available

Original error: Error
    at Stream.<anonymous> (/usr/lib/node_modules/exoframe/dist/index.js:67005:19)
    at Stream.emit (events.js:321:20)
    at Stream.module.exports.Stream._send (/usr/lib/node_modules/exoframe/dist/index.js:78968:18)
    at push (/usr/lib/node_modules/exoframe/dist/index.js:79490:19)
    at /usr/lib/node_modules/exoframe/dist/index.js:80521:17
    at Stream.s._send (/usr/lib/node_modules/exoframe/dist/index.js:79524:9)
    at Stream.module.exports.Stream.write (/usr/lib/node_modules/exoframe/dist/index.js:79625:18)
    at Stream.module.exports.Stream._send (/usr/lib/node_modules/exoframe/dist/index.js:78948:26)
    at push (/usr/lib/node_modules/exoframe/dist/index.js:79490:19)
    at /usr/lib/node_modules/exoframe/dist/index.js:81135:13 {
  response: { level: 'error' }
}
Original response: { level: 'error' }

My Server:

OS: Debian 10
RAM: 8GB
SSD: 100GB

When i run exoframe logs exoframe-server i will get this output:

Getting logs for deployment: exoframe-server 
Error while getting logs: HTTPError: Response code 503 (Service Unavailable)

How can i solve this issue? Note: it seems all deployment templates do not work, not only nodejs projects

niklasgrewe commented 4 years ago

I don't know if this is helpful, but my Nodejs application is listening on port 3000 my package.json looks like this:

{
  "name": "grewe.io",
  "description": "Website about Niklas Grewe",
  "version": "0.0.1",
  "scripts": {
    "dev": "sapper dev",
    "build": "npm run build:tailwind && sapper build",
    "export": "sapper export --legacy",
    "start": "node __sapper__/build",
    "cy:run": "cypress run",
    "cy:open": "cypress open",
    "test": "run-p --race dev cy:run",
    "watch:tailwind": "postcss static/tailwind.css -o static/index.css -w",
    "build:tailwind": "NODE_ENV=production postcss static/tailwind.css -o static/index.css"
}

and my server.js looks like this:

import sirv from 'sirv';
import polka from 'polka';
import compression from 'compression';
import * as sapper from '@sapper/server';

const { PORT, NODE_ENV } = process.env;
const dev = NODE_ENV === 'development';

polka() // You can also use Express
    .use(
        compression({ threshold: 0 }),
        sirv('static', { dev }),
        sapper.middleware()
    )
    .listen(PORT, err => {
        if (err) console.log('error', err);
    });
yamalight commented 4 years ago

@niklasgrewe seems like something goes wrong immediately after docker build. could you please share the logs from exoframe-server using docker logs exoframe-server[-hash] command on your server?

yamalight commented 4 years ago

@niklasgrewe I think I might've figured out why that happens. could you please also try removing exoframe-plugin-swarm from plugins, restarting server and trying to deploy again?

niklasgrewe commented 4 years ago

@yamalight when i remove the exoframe-plugin-swarm from plugins, deployment works:

Your project is now deployed as:

   ID                                URL            Hostname       Type        
   exo-id...                       grewe.io       Not set        Container

but when i surfe to grewe.io i get the error in Browser Window: Bad Gateway How can i fix that?

yamalight commented 4 years ago

@niklasgrewe seems like you are not using port 80 for your deployment. you either need to use port 80 (see docs), or pass a traefik label with your port, or define a custom Dockerfile that uses your port

niklasgrewe commented 4 years ago

@yamalight it works now... thanks for your help