-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
64 lines (45 loc) · 1.37 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
FROM node:14-alpine AS ts-build
RUN mkdir -p /app
COPY package.json yarn.lock /app/
WORKDIR /app
# Install Node dependencies
RUN yarn install
# Copy source files
COPY ./src /app/src
COPY ./bin /app/bin
COPY ./config /app/config
COPY tsconfig.json /app
# Build/transpile from ts to js
RUN yarn build
# Generate build container
FROM node:14-alpine
LABEL Maintainer="Gonzalo Plaza <[email protected]>" \
Description="Lightweight container with Node 14 based on Alpine Linux"
# Environment vars
ARG NODE_ENV=development
ENV NODE_CONFIG_STRICT_MODE=1
ENV NODE_ENV=$NODE_ENV
ENV APP_NAME=cognito-workshop
ENV APP_LOG_LEVEL=debug
ENV AWS_ACCESS_KEY_ID=""
ENV AWS_SECRET_ACCESS_KEY=""
ENV COGNITO_USER_POOL=""
ENV COGNITO_CLIENT_ID=""
ENV COGNITO_REGION=""
ENV PORT=3000
# Install Alpine dependencies
RUN apk --no-cache add supervisor && \
rm -rf /var/cache/apk/*
# Configure supervisord
COPY ./etc/supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
RUN mkdir -p /app /app/logs
WORKDIR /app
COPY package.json yarn.lock /app/
# Install production Node dependencies
RUN yarn install --production
# Copy nodels build from previous stage
COPY --from=ts-build /app/dist /app/
# Expose the port nginx is reachable on
EXPOSE ${PORT}
# Let supervisord start nginx && node js built app
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]