30 lines
882 B
Docker
30 lines
882 B
Docker
# BASE DOCKER IMAGE DOCKERFILE:
|
|
ARG ECR_URL="059081848155.dkr.ecr.ap-northeast-1.amazonaws.com"
|
|
ARG NODE_VERSION="8.11.4"
|
|
ARG IMAGE="$ECR_URL/node-alpine:$NODE_VERSION"
|
|
|
|
FROM "$IMAGE" as intermediate
|
|
# add credentials on build
|
|
ARG SSH_PRIVATE_KEY
|
|
RUN mkdir -p $HOME_DIR/.ssh
|
|
RUN echo "${SSH_PRIVATE_KEY}" > $HOME_DIR/.ssh/id_rsa
|
|
RUN chown -R $CONTAINER_USER:$CONTAINER_USER $HOME_DIR && \
|
|
chmod 700 $HOME_DIR/.ssh && \
|
|
chmod 600 $HOME_DIR/.ssh/id_rsa
|
|
|
|
USER $CONTAINER_USER
|
|
COPY --chown=node:node package.json /tmp/package.json
|
|
RUN eval `ssh-agent -s` && ssh-add $HOME_DIR/.ssh/id_rsa
|
|
RUN cd /tmp && npm cache clean --force
|
|
RUN cd /tmp && npm install
|
|
|
|
# Use the image without sshkey
|
|
FROM "$IMAGE"
|
|
LABEL description="nixplay-mobile-react"
|
|
RUN mkdir -p $HOME_DIR/app
|
|
COPY --from=intermediate /tmp/node_modules $HOME_DIR/app/node_modules
|
|
COPY . $HOME_DIR/app/
|
|
|
|
WORKDIR $HOME_DIR/app
|
|
|