-
-
Save muyiwadosunmu/2b6e5cc2c93a7136a13122880d318c35 to your computer and use it in GitHub Desktop.
Node Dockerization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Use leightweight linux distrubution | |
| # Choose alpine because it's size only 5MB | |
| FROM alpine:3.7 | |
| ENV NVM_DIR /usr/local/nvm | |
| ENV NODE_ENV=local | |
| ENV PORT=4044 | |
| ENV JWT_ACCESS_TOKEN=iamdeveloper | |
| ENV JWT_REFRESH_TOKEN=iamdevelopertoo | |
| ENV JWT_EXPIRATION=60m | |
| ENV JWT_REFRESH_EXPIRATION=5h | |
| ENV EMAIL_ADDRESS= | |
| ENV EMAIL_PASSWORD= | |
| # AWS configuration | |
| ENV BUCKET_NAME=tigrow-file | |
| ENV AWS_ACCESS_KEY= | |
| ENV AWS_SECRET_ACCESS_KEY= | |
| ENV S3_REGION=ap-southeast-1 | |
| ENV AWS_UPLOADED_FILE_URL_LINK= | |
| # RUN apk add nodejs=12.14.0-r0 | |
| RUN apk add --no-cache --virtual .gyp python make g++ | |
| RUN apk add --update nodejs | |
| RUN npm cache verify | |
| # Add Maintainer info | |
| LABEL maintainer="orvidas12@gmail.com" | |
| # avoid container running as 'root' | |
| RUN addgroup -S orvi && adduser -S -G orvi orvi | |
| # set /app directory as default working directory | |
| WORKDIR /app | |
| # taking advantages of docker layer cache system | |
| ADD package.json /app/package.json | |
| # install all desired packages | |
| RUN npm install | |
| #for production | |
| # RUN npm ci --only=production | |
| # copy all file from current dir to /app in container | |
| COPY . /app | |
| # expose port 4044 | |
| EXPOSE 4044 | |
| # cmd to start service | |
| CMD [ "npm", "start" ] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment