Last active
July 18, 2018 23:18
-
-
Save iMerica/6bc08f4d13316889d4e08110353ef70c to your computer and use it in GitHub Desktop.
Automated Deployments of Create React Apps to Cloudfront using Scotty JS.
This file contains 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
image: docker:latest | |
services: | |
- docker:dind | |
stages: | |
- build | |
- push | |
- deploy | |
variables: | |
REACT_TAG_NAME: registry.gitlab.com/<user>/<project>/<container-name>:$CI_COMMIT_REF_NAME | |
S3_BUCKET: xxxx | |
before_script: | |
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com | |
build:react: | |
artifacts: | |
paths: | |
- docker-images | |
stage: build | |
script: | |
- mkdir docker-images | |
- docker build --pull -t $REACT_TAG_NAME -f path/to/your/Dockerfile . | |
- docker save $REACT_TAG_NAME > docker-images/react.tar | |
push:react: | |
stage: push | |
script: | |
- docker load -i docker-images/react.tar | |
- docker push $REACT_TAG_NAME | |
only: | |
- master | |
deploy:react: | |
stage: deploy | |
script: | |
- docker run \ | |
--rm \ | |
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \ | |
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \ | |
$REACT_TAG_NAME \ | |
--source /tmp/build/ \ | |
--region us-east-1 \ | |
--bucket $S3_BUCKET \ | |
--urlonly \ | |
--spa |
This file contains 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:8.11.3-slim as node_builder | |
MAINTAINER @iMichael | |
WORKDIR /app | |
COPY /src /app/src | |
RUN cd /app/src && \ | |
npm install && \ | |
npm run build | |
FROM node:8.11.3-slim as deployer | |
RUN groupadd -r react && useradd -r -g react react | |
RUN npm install scottyjs --global | |
COPY --from=node_builder /app/src/build /tmp/build | |
USER react | |
ENTRYPOINT ["scotty"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment