feat(docker): add docker via Circle CI (#212) r=jbuck,seanmonstar
Fixes #208
This commit is contained in:
Родитель
70dcc5b899
Коммит
8f913be7fd
11
Dockerfile
11
Dockerfile
|
@ -1,11 +0,0 @@
|
|||
FROM ubuntu:trusty
|
||||
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get -y update && DEBIAN_FRONTEND=noninteractive apt-get -y install nodejs npm git
|
||||
RUN ln -sf /usr/bin/nodejs /usr/local/bin/node
|
||||
|
||||
RUN useradd --home-dir /opt/fxa fxa
|
||||
USER fxa
|
||||
|
||||
WORKDIR /opt/fxa
|
||||
|
||||
CMD npm start
|
|
@ -0,0 +1,19 @@
|
|||
FROM mhart/alpine-node:4.8.0
|
||||
|
||||
RUN addgroup -g 10001 app && \
|
||||
adduser -D -G app -h /app -u 10001 app
|
||||
WORKDIR /app
|
||||
|
||||
# S3 bucket in Cloud Services prod IAM
|
||||
ADD https://s3.amazonaws.com/dumb-init-dist/v1.2.0/dumb-init_1.2.0_amd64 /usr/local/bin/dumb-init
|
||||
RUN chmod +x /usr/local/bin/dumb-init
|
||||
ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]
|
||||
|
||||
USER app
|
||||
|
||||
COPY npm-shrinkwrap.json npm-shrinkwrap.json
|
||||
COPY package.json package.json
|
||||
|
||||
RUN npm install --production && rm -rf ~app/.npm /tmp/*
|
||||
|
||||
COPY . /app
|
|
@ -0,0 +1,2 @@
|
|||
FROM fxa-auth-db-mysql:build
|
||||
RUN npm install
|
21
README.md
21
README.md
|
@ -1,6 +1,7 @@
|
|||
# Firefox Accounts database service
|
||||
|
||||
[![Build Status][ci-status-icon]][ci-status]
|
||||
[![CircleCI](https://circleci.com/gh/mozilla/fxa-auth-db-mysql.svg?style=svg)](https://circleci.com/gh/mozilla/fxa-auth-db-mysql)
|
||||
|
||||
Node.js-based database service
|
||||
for Firefox Accounts.
|
||||
|
@ -171,26 +172,6 @@ mysql -u root -p -e 'DROP DATABASE fxa'
|
|||
It will be recreated automatically
|
||||
next time you run `npm start`.
|
||||
|
||||
### Docker-based development
|
||||
|
||||
To run the MySQL backend
|
||||
inside a container,
|
||||
use the following commands:
|
||||
|
||||
```sh
|
||||
docker build --rm -t mozilla/fxa_auth_db_mysql .
|
||||
docker run --rm -v $PWD:/opt/fxa mozilla/fxa_auth_db_mysql npm install
|
||||
docker run -it --rm -v $PWD:/opt/fxa --net=host mozilla/fxa_auth_db_mysql
|
||||
```
|
||||
|
||||
This method shares the codebase
|
||||
into a container
|
||||
and runs the MySQL backend inside it.
|
||||
You can `npm install`
|
||||
and edit code
|
||||
in your normal desktop environment
|
||||
and the changes will be picked up automatically.
|
||||
|
||||
## License
|
||||
|
||||
[MPL 2.0][license]
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
# 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
|
||||
- mysql
|
||||
|
||||
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 fxa-auth-db-mysql:build .
|
||||
- docker build -f Dockerfile-test -t fxa-auth-db-mysql:test .
|
||||
|
||||
test:
|
||||
override:
|
||||
- docker run --net="host" fxa-auth-db-mysql:test npm 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 fxa-auth-db-mysql: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 fxa-auth-db-mysql:build ${DOCKERHUB_REPO}:${CIRCLE_TAG}"
|
||||
- "docker images"
|
||||
- "docker push ${DOCKERHUB_REPO}:${CIRCLE_TAG}"
|
Загрузка…
Ссылка в новой задаче