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:
|
build:
|
||||||
context: ..
|
context: ..
|
||||||
dockerfile: ./docker/server/Dockerfile
|
dockerfile: ./docker/server/Dockerfile
|
||||||
|
args:
|
||||||
|
- PORT=3000
|
||||||
|
- REDIS_HOST=redis
|
||||||
|
- REDIS_PORT=6379
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
- PORT=3000
|
- PORT=3000
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,15 @@ RUN npm run build
|
||||||
|
|
||||||
FROM base as app
|
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
|
COPY --chown=node:node --from=builder /app/dist ./dist
|
||||||
|
|
||||||
ENTRYPOINT ["node", "./dist/main.js"]
|
ENTRYPOINT ["node", "./dist/main.js"]
|
||||||
|
|
@ -6,10 +6,10 @@ import { CustomResponseTransformInterceptor } from './common/customResponse'
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
const app = await NestFactory.create(AppModule, { abortOnError: false })
|
const app = await NestFactory.create(AppModule, { abortOnError: false })
|
||||||
const config = app.get(ConfigService)
|
const config = app.get(ConfigService)
|
||||||
const port = config.get('PORT')
|
const port = config.get('PORT', 3000)
|
||||||
app.enableShutdownHooks()
|
app.enableShutdownHooks()
|
||||||
app.useGlobalInterceptors(new CustomResponseTransformInterceptor())
|
app.useGlobalInterceptors(new CustomResponseTransformInterceptor())
|
||||||
await app.listen(port)
|
await app.listen(port, () => console.log(`Listening on port ${port}`))
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrap()
|
bootstrap()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue