Developing and version control in a shared data-container

353 views Asked by At

I'm working on an OpenERP project where I'm working on a few custom modules. I have a 3 container setup:

  • app: OpenERP service running here
  • db: PostgreSQL service, nothing else
  • data: only a volume directory and serves as a data provider for 'app' container

It's working fine but if I want to work on the files in the data container I don't know what is the fastest and best way to use proper IDE and if I'm done, commit the code and actually keep it after I shut the container down?

One approach would be to create another container with shared X11 service and lach onto that with a GUI based IDE or something similar but this seems a bit overkill for me.

Regarding version control: I have a remote git repo that might be good for storing the changes but as soon as I build the image from a Dockerfile and spin it up, it can't clone the repo because it only allows SSH connection and the container doesn't have it.

I found several articles and blog posts about shared data containers and how awesome they are. I haven't been able to found another where they discussed the actual development and committing of the code on these data conatiners.

Thoughts?

1

There are 1 answers

2
dukebody On BEST ANSWER

You don't need a container with shared X11 service or using git to clone your code repo from the container.

For development, you can mount your code folder using volumes in your "data" container and then your "app" container will see these files (see https://docs.docker.com/userguide/dockervolumes/):

sudo docker run -d -P --name data -v /src/webapp:/opt/webapp my/container

Since this folder will be in the host machine, it will be persisted after the "data" container is shut down. You will also be able to use your favorite IDE to edit the code.

For production you can ADD the code folder into the container image itself so you can deploy the container directly. In your Dockerfile:

ADD /home/user/webapp /opt/webapp

Also, see Embed code in docker container or mount it as a volume? for a short discussion of this approach.