2

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:

  1. publish repo incl. the initial db data on github
  2. triggering travis ci to test/lint
  3. triggering codedeploy to deploy to ec2 instance
  4. 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
fheck
  • 280
  • 1
  • 5
  • 15
  • What exactly are you trying to do? I see that `data` is in your `.gitignore`, but were some files committed to that folder first? Note that `git update-index --assume-unchanged` is a local command, and won't affect any remote repos, so that's probably not what you want. – Scott Weldon Oct 28 '16 at 15:41
  • 1
    Yep, the initial data are on github. The `data` entry in `.gitignore` was added after the commit/push. Yeah, I know it's a local command. But I ran the command on the remote machine and hoped that the data directory doesn't get overwritten because git says that nothing has changed. – fheck Oct 28 '16 at 16:02
  • So what is the goal? I assume you don't want to just remove the file from the repo now that the data has been imported? Do you just want a way to import the data only if no data exists? – Scott Weldon Oct 28 '16 at 16:15
  • Yeah, exactly. I just want a way to import the data only if no data exists. So that there is an initial state. But as soon as the live/remote system has additional data, it should not be overwritten anymore. – fheck Oct 28 '16 at 16:32
  • How is the data imported currently? – Scott Weldon Oct 28 '16 at 17:05
  • To the remote system? With the github-travis-codedeploy pipeline.. – fheck Oct 28 '16 at 17:09
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/126925/discussion-between-fheck-and-scott-weldon). – fheck Oct 28 '16 at 17:10

0 Answers0