This repository has been archived by the owner on Apr 3, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docker): Add CloudOps Dockerfile & CircleCI build instructions
- Loading branch information
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM node:4.5.0 | ||
|
||
RUN groupadd --gid 10001 app && \ | ||
useradd --uid 10001 --gid 10001 --home /app --create-home app | ||
|
||
USER app | ||
|
||
WORKDIR /app | ||
|
||
COPY scripts/gen_keys.js scripts/gen_keys.js | ||
COPY package.json package.json | ||
|
||
RUN npm install && \ | ||
npm cache clear && \ | ||
rm -rf ~app/.node-gyp ~app/.npm | ||
|
||
COPY . /app | ||
|
||
ENTRYPOINT ["/app/scripts/docker-exec.sh"] | ||
CMD ["test"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# These environment variables must be set in CircleCI UI | ||
# | ||
# DOCKERHUB_REPO - docker hub repo, format: <username>/<repo> | ||
# DOCKER_EMAIL - login info for docker hub | ||
# DOCKER_USER | ||
# DOCKER_PASS | ||
# | ||
machine: | ||
services: | ||
- docker | ||
dependencies: | ||
override: | ||
- docker info | ||
|
||
- > | ||
printf '{"version":{"hash":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}}\n' | ||
"$CIRCLE_SHA1" | ||
"$CIRCLE_TAG" | ||
"$CIRCLE_PROJECT_USERNAME" | ||
"$CIRCLE_PROJECT_REPONAME" | ||
"$CIRCLE_BUILD_URL" | ||
| tee config/version.json version.json | ||
- docker build -f Dockerfile-build -t app:build . | ||
|
||
test: | ||
override: | ||
- docker run app:build test | ||
|
||
# appropriately tag and push the container to dockerhub | ||
deployment: | ||
hub_latest: | ||
branch: "master" | ||
commands: | ||
- "[ ! -z $DOCKERHUB_REPO ]" | ||
- docker login -e "$DOCKER_EMAIL" -u "$DOCKER_USER" -p "$DOCKER_PASS" | ||
- "docker tag app:build ${DOCKERHUB_REPO}:latest" | ||
- "docker push ${DOCKERHUB_REPO}:latest" | ||
|
||
hub_releases: | ||
# push all tags | ||
tag: /.*/ | ||
commands: | ||
- "[ ! -z $DOCKERHUB_REPO ]" | ||
- docker login -e "$DOCKER_EMAIL" -u "$DOCKER_USER" -p "$DOCKER_PASS" | ||
- "echo ${DOCKERHUB_REPO}:${CIRCLE_TAG}" | ||
- "docker tag app:build ${DOCKERHUB_REPO}:${CIRCLE_TAG}" | ||
- "docker images" | ||
- "docker push ${DOCKERHUB_REPO}:${CIRCLE_TAG}" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ "$1" == "test" ]; then | ||
exec npm test | ||
elif [ "$1" == "web" ]; then | ||
exec node bin/server.js | ||
elif [ "$1" == "internal" ]; then | ||
exec node bin/internal.js | ||
elif [ "$1" == "purge_expired_tokens" ]; then | ||
exec node bin/purge_expired_tokens.js | ||
elif [ "$1" == "gen_keys" ]; then | ||
exec node scripts/gen_keys.js | ||
else | ||
echo "unknown mode: $1" | ||
exit 1 | ||
fi |
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