Adding some changes to dockerfile to use env vars for ports and redis config
This commit is contained in:
parent
1def4de40c
commit
1e2933e780
3 changed files with 15 additions and 2 deletions
|
|
@ -3,6 +3,10 @@ services:
|
|||
build:
|
||||
context: ..
|
||||
dockerfile: ./docker/server/Dockerfile
|
||||
args:
|
||||
- PORT=3000
|
||||
- REDIS_HOST=redis
|
||||
- REDIS_PORT=6379
|
||||
restart: always
|
||||
environment:
|
||||
- PORT=3000
|
||||
|
|
|
|||
|
|
@ -42,6 +42,15 @@ RUN npm run build
|
|||
|
||||
FROM base as app
|
||||
|
||||
ARG PORT=3000
|
||||
ENV PORT=$PORT
|
||||
|
||||
ARG REDIS_HOST=localhost
|
||||
ENV REDIS_HOST=$REDIS_HOST
|
||||
|
||||
ARG REDIS_PORT=6379
|
||||
ENV REDIS_PORT=$REDIS_PORT
|
||||
|
||||
COPY --chown=node:node --from=builder /app/dist ./dist
|
||||
|
||||
ENTRYPOINT ["node", "./dist/main.js"]
|
||||
|
|
@ -6,10 +6,10 @@ import { CustomResponseTransformInterceptor } from './common/customResponse'
|
|||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule, { abortOnError: false })
|
||||
const config = app.get(ConfigService)
|
||||
const port = config.get('PORT')
|
||||
const port = config.get('PORT', 3000)
|
||||
app.enableShutdownHooks()
|
||||
app.useGlobalInterceptors(new CustomResponseTransformInterceptor())
|
||||
await app.listen(port)
|
||||
await app.listen(port, () => console.log(`Listening on port ${port}`))
|
||||
}
|
||||
|
||||
bootstrap()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue