Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing Docker build #894

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 39 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,62 @@
sudo: required
language: generic

language: node_js
node_js:
- lts/*
env:
global:
- IMAGE_TAG=${TRAVIS_COMMIT::7}

before_install:
# Removed command as pyenv is no longer found during deploy
#- pyenv global 2.7.14 # For removing SNIMissingWarning warnings
- curl https://install.meteor.com | /bin/sh
- export PATH="$HOME/.meteor:$PATH"
- pip install --user awscli
# Used in deploy.sh
- export PATH=$PATH:$HOME/.local/bin
- curl -o $HOME/.local/bin/ecs-cli
https://s3.amazonaws.com/amazon-ecs-cli/ecs-cli-linux-amd64-latest &&
chmod +x $HOME/.local/bin/ecs-cli

cache:
directories:
- node_modules

install:
- meteor npm install

script:
- npm t
after_success:
- docker build -t $DOCKER_CI_REPO_NAME:latest .
# TODO: this should only happen really on branch = master
- docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
- docker tag $DOCKER_CI_REPO_NAME:latest $DOCKER_CI_REPO_NAME:$IMAGE_TAG
- docker push $DOCKER_CI_REPO_NAME:latest
- docker push $DOCKER_CI_REPO_NAME:$IMAGE_TAG

matrix:
include:
- env: DEPLOY=none
# add deploy stage for dev
- env: DEPLOY=dev
if: branch = master
deploy:
provider: script
script: TRAVIS_DOCKER_REPO_NAME=$DOCKER_CI_REPO_NAME
TRAVIS_PROFILE=$AWS_PROFILE_DEV
TRAVIS_AWS_ACCESS_KEY_ID=$AWS_ACCOUNT_USER_ID_DEV
TRAVIS_AWS_SECRET_ACCESS_KEY=$AWS_ACCOUNT_SECRET_DEV
TRAVIS_AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION
./deploy.sh
on:
branch: master
- env: DEPLOY=demo
if: tag IS present
deploy:
provider: script
skip_cleanup: true
script: AWS_ACCESS_KEY_ID=$AWS_915001051872_ID AWS_SECRET_ACCESS_KEY=$AWS_915001051872_SECRET ./deploy.sh -d
script: PROFILE=$AWS_PROFILE_DEMO
AWS_ACCESS_KEY_ID=$AWS_ACCOUNT_USER_ID_DEMO
AWS_SECRET_ACCESS_KEY=$AWS_ACCOUNT_SECRET_DEMO
AWS_REGION=$AWS_DEFAULT_REGION
./deploy.sh -d
on:
tags: true
- env: DEPLOY=prod
if: tag IS present
deploy:
provider: script
skip_cleanup: true
script: AWS_ACCESS_KEY_ID=$AWS_192458993663_ID AWS_SECRET_ACCESS_KEY=$AWS_192458993663_SECRET ./deploy.sh -p && AWS_ACCESS_KEY_ID=$AWS_192458993663_ID AWS_SECRET_ACCESS_KEY=$AWS_192458993663_SECRET aws cloudfront create-invalidation --distribution-id E173XT6X8V4A18 --paths '/*'
script: PROFILE=$AWS_PROFILE_PROD
AWS_ACCESS_KEY_ID=$AWS_ACCOUNT_USER_ID_PROD
AWS_SECRET_ACCESS_KEY=$AWS_ACCOUNT_SECRET_PROD
AWS_REGION=$AWS_DEFAULT_REGION
./deploy.sh -p &&
# TODO distribition ID should probably be an ENV variable
AWS_ACCESS_KEY_ID=$AWS_ACCOUNT_USER_ID_PROD
AWS_SECRET_ACCESS_KEY=$AWS_ACCOUNT_SECRET_PROD
aws cloudfront create-invalidation --distribution-id E173XT6X8V4A18 --paths '/*'
on:
tags: true

env:
global:
- COMMIT=${TRAVIS_COMMIT::7}
32 changes: 20 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
FROM node:8 AS builder
FROM node:8.15.1 AS builder

RUN curl -sL https://install.meteor.com | sed s/--progress-bar/-sL/g | /bin/sh
RUN mkdir /src /bundle
RUN chown -R node /src /bundle
ENV BUNDLE_DIR /home/node/bundle
ENV SRC_DIR /home/node/src
ENV TMP_DIR /home/node/tmp

USER node:node

WORKDIR /src
COPY --chown=node:node . .
RUN mkdir -p $SRC_DIR $BUNDLE_DIR $TMP_DIR
COPY --chown=node:node . $SRC_DIR

RUN meteor npm install
RUN meteor build --architecture os.linux.x86_64 --directory /bundle
RUN cd /bundle/bundle/programs/server && npm install
RUN curl -o $TMP_DIR/meteor.sh 'https://install.meteor.com?release=1.8.1'; sh $TMP_DIR/meteor.sh

FROM node:8-slim
ENV PATH="/home/node/.meteor:${PATH}"
WORKDIR $SRC_DIR
RUN npm i
RUN meteor npm install --production
RUN meteor build --server-only --directory $BUNDLE_DIR
RUN cd ${BUNDLE_DIR}/bundle/programs/server && npm install

FROM node:8.15.1-slim

ENV APP_DIR /home/node/app
ENV BUNDLE_DIR /home/node/bundle

USER node:node

COPY --from=builder /bundle /app
WORKDIR /app/bundle
COPY --from=builder $BUNDLE_DIR $APP_DIR
WORKDIR $APP_DIR/bundle

ENV PORT 3000
EXPOSE 3000
Expand Down
39 changes: 0 additions & 39 deletions buildspec.yml

This file was deleted.