I'm currently developing a node.js project based on docker-compose
, which handles the app itself and a mongo database. In the database is an initial user stored.
I've got an idea how it should work initially:
- publish repo incl. the initial db data on github
- triggering travis ci to test/lint
- triggering codedeploy to deploy to ec2 instance
- run build command and run
docker-compose up
Now the app should be online. While the production mode the database gets some more data. When pushing again to master, it should deploy again but must not override the live data with the initial data on github. Currently the whole process works but still overrides the data. I ran the following command on both the local and the remote machine, but without any success:
cd ./data && git ls-files | tr '\n' ' ' | xargs git update-index --assume-unchanged
I thought that codedeploy just pulls the current master branch but ignores the ./data
directory because of the command above and the .gitignore
file. But it does not seem so.
So is there anything that's missed so far? Hope you've got some hints and ideas how to solve this issue.
Thanks a lot!!
p.s. following some information and file excerpts.
System Details
- Ubuntu 14.04.4 LTS
- node: v6.9.1
- npm: 3.10.8
- docker: 1.12.3
- docker-compose: 1.8.1
- git: 1.91
File structure
config/ # Some config files
data/ # The database its directory
src/ # The source files
.gitignore
.travis.yml
appspec.yml
docker-compose.yml
Here are some file excerpts:
.gitignore
data/*
.travis.yml
language: node_js
sudo: required
dist: trusty
node_js:
- 6
before_script:
- npm install
script:
- npm run lint
branches:
only:
- master
deploy:
provider: codedeploy
wait-until-deployed: true
access_key_id: 'mykeyid'
secret_access_key: 'myaccesskey'
application: appname
deployment_group: grpname
region: eu-central-1
appspec.yml
version: 0.0
os: linux
files:
- source: /
destination: /home/ubuntu/app
permissions:
- object: /
pattern: "**"
owner: ubuntu
docker-compose.yml
version: '2'
services:
server:
image: node:6
command: 'npm run go'
working_dir: '/app'
volumes:
- ./:/app
depends_on:
- mongo
ports:
- '1337:1337'
environment:
- NODE_ENV=prod
links:
- mongo:mongodb
mongo:
image: mongo:latest
ports:
- '127.0.0.1:27017:27017'
volumes:
- ./data/:/data/db