Created
February 9, 2016 23:37
-
-
Save andrewmclagan/c3af8fcad799fbe02ef0 to your computer and use it in GitHub Desktop.
react-redux-universal-hot-example Sample Dockerfile with AWS S3 static asset upload
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
FROM node:5.1.1 | |
#Install AWS CLI | |
RUN apt-get update | |
RUN apt-get install -y python-pip | |
RUN pip install awscli | |
RUN mkdir -p /root/.aws | |
RUN echo '[default]' > /root/.aws/config | |
RUN echo 'output = json' >> /root/.aws/config | |
RUN echo 'region = us-east-1' >> /root/.aws/config | |
RUN echo '[default]' > /root/.aws/credentials | |
RUN echo 'aws_access_key_id = AWS_ACCESS_KEY' >> /root/.aws/credentials | |
RUN echo 'aws_secret_access_key = AWS_SECRET_KEY' >> /root/.aws/credentials | |
RUN chmod 600 /root/.aws/config | |
RUN chmod 600 /root/.aws/credentials | |
# cache npm install when package.json hasn't changed | |
WORKDIR /tmp | |
ADD package.json package.json | |
RUN npm install | |
RUN npm install -g pm2 | |
RUN mkdir /project | |
RUN cp -a /tmp/node_modules /project | |
WORKDIR /project | |
ADD . /project/ | |
ENV NODE_ENV production | |
ENV API_URL SOME_URL | |
ENV ASSETS_URL https://CLOUDFRONT_ID.cloudfront.net/assets/ | |
RUN npm run build | |
# upload js and css | |
WORKDIR /project/build | |
# UPLOAD TO S3! | |
WORKDIR /project/static | |
RUN aws s3 cp dist s3://AWS_ASSETS_PATH/assets --recursive --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers | |
# go back to /project | |
WORKDIR /project | |
ENV NODE_PATH "./src" | |
ENV HOST 127.0.0.1 | |
ENV PORT 8000 | |
ENV DISABLE_SSR false | |
EXPOSE 8000 | |
CMD ["pm2", "start", "./bin/server.js", "--no-daemon", "-i", "0"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment