File tree 10 files changed +26
-33
lines changed
10 files changed +26
-33
lines changed Original file line number Diff line number Diff line change 1
1
PORT = 3000
2
- HOST = localhost
3
- ENV = development
2
+ HOST = 0.0.0.0
4
3
HTTPS = false
5
-
6
- # Could be left empty if you don't want to use it
7
- # API_KEY=
8
- # CLUSTER=false
4
+ EXPOSE_PORT = 3000 # only used with docker-compose
Original file line number Diff line number Diff line change 9
9
10
10
variables :
11
11
NODE_VERSION : " 18.17.0"
12
- PM2 : " servant "
12
+ PM2 : " feed-renderer "
13
13
14
14
deploy-job :
15
15
stage : deploy
@@ -29,7 +29,6 @@ deploy-job:
29
29
git pull &&
30
30
/home/$SSH_USER/.nvm/versions/node/v$NODE_VERSION/bin/pnpm i &&
31
31
/home/$SSH_USER/.nvm/versions/node/v$NODE_VERSION/bin/pnpm build &&
32
- pm2 restart $PM2 &&
33
32
notifier '$CI_PROJECT_TITLE deployed'"
34
33
only :
35
34
- main
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ RUN pnpm build
13
13
14
14
ENV PORT=3000
15
15
ENV HOST=0.0.0.0
16
- ENV ENV=development
17
16
ENV HTTPS=false
18
17
19
18
EXPOSE 3000
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ Some podcast services offer a RSS feed with HTML render if RSS feed is requested
17
17
18
18
### Docker
19
19
20
- You can use ` docker- compose ` or ` docker ` to run the application.
20
+ You can use ` docker compose ` or ` docker ` to run the application.
21
21
22
22
#### Docker compose
23
23
@@ -30,16 +30,16 @@ cp .env.example .env
30
30
Docker compose will use the ` .env ` file to set environment variables.
31
31
32
32
``` bash
33
- docker- compose up -d
33
+ docker compose up -d
34
34
```
35
35
36
36
#### Docker image
37
37
38
38
Build and run the docker image
39
39
40
40
``` bash
41
- docker build -t feed-renderer .
42
- docker run -it -p 3000:3000 feed-renderer
41
+ docker build -t feed_renderer:app .
42
+ docker run -it -p 3000:3000 feed_renderer:app
43
43
```
44
44
45
45
### Local
Original file line number Diff line number Diff line change 2
2
version : " 3"
3
3
services :
4
4
feed_renderer :
5
- container_name : feed_renderer
5
+ container_name : app
6
6
build :
7
7
context : .
8
8
dockerfile : Dockerfile
9
9
ports :
10
- - " ${PORT}:3000 "
10
+ - " ${EXPOSE_PORT}:${PORT} "
11
11
env_file : .env
12
12
restart : always
Original file line number Diff line number Diff line change 6
6
"type" : " module" ,
7
7
"main" : " index.js" ,
8
8
"scripts" : {
9
- "start" : " listhen ./dist/index.js" ,
9
+ "start" : " listhen --public=false ./dist/index.js" ,
10
10
"dev" : " listhen -w ./src/index.ts" ,
11
11
"build" : " tsup" ,
12
12
"build:fix" : " esno scripts/postbuild.ts" ,
13
- "preview" : " node ./dist/index.js" ,
14
13
"test" : " vitest" ,
15
14
"coverage" : " vitest run --coverage" ,
16
15
"lint" : " eslint ." ,
Original file line number Diff line number Diff line change 1
1
import { createApp } from 'h3'
2
2
import { router } from './router'
3
+ import { Dotenv } from './services'
4
+
5
+ const dotenv = Dotenv . load ( )
6
+ console . error ( dotenv )
3
7
4
8
export const app = createApp ( )
5
9
app . use ( router )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ /* eslint-disable n/prefer-global/process */
1
2
import 'dotenv/config'
2
3
3
4
interface IDotenv {
@@ -6,30 +7,29 @@ interface IDotenv {
6
7
HTTPS : boolean
7
8
BASE_URL : string
8
9
IS_DEV : boolean
10
+ NODE_ENV ?: string
9
11
}
10
12
11
13
export class Dotenv {
12
14
public static load ( ) : IDotenv {
13
- // eslint-disable-next-line n/prefer-global/process
14
- const current = process
15
-
16
- let port = current . env . PORT ?? 3000
15
+ let port = process . env . PORT ?? 3000
17
16
port = Number ( port )
18
- const host = current . env . HOST ?? 'localhost '
19
- const https = current . env . HTTPS === 'true'
17
+ const host = process . env . HOST ?? '0.0.0.0 '
18
+ const https = process . env . HTTPS === 'true'
20
19
const prefix = https ? 'https' : 'http'
21
- const isDev = current . env . ENV === 'development '
20
+ const isProduction = process . env . NODE_ENV === 'production '
22
21
23
22
let baseURL = `${ prefix } ://${ host } `
24
- if ( isDev )
23
+ if ( ! isProduction )
25
24
baseURL = `${ baseURL } :${ port } `
26
25
27
26
return {
28
27
PORT : port ,
29
28
HOST : host ,
30
29
HTTPS : https ,
31
30
BASE_URL : baseURL ,
32
- IS_DEV : isDev ,
31
+ NODE_ENV : process . env . NODE_ENV ,
32
+ IS_DEV : ! isProduction ,
33
33
}
34
34
}
35
35
}
Original file line number Diff line number Diff line change @@ -10,4 +10,7 @@ export default <Options>{
10
10
format : [ 'cjs' , 'esm' ] ,
11
11
dts : false ,
12
12
onSuccess : 'npm run build:fix' ,
13
+ env : {
14
+ NODE_ENV : 'production' ,
15
+ } ,
13
16
}
You can’t perform that action at this time.
0 commit comments