Skip to content

Dockerfile.dev for development#33

Open
WoZ wants to merge 3 commits intomasterfrom
docker-dev-support
Open

Dockerfile.dev for development#33
WoZ wants to merge 3 commits intomasterfrom
docker-dev-support

Conversation

@WoZ
Copy link
Copy Markdown
Member

@WoZ WoZ commented Oct 3, 2017

Development and testing process should be unified. Docker is a good candidate.

Build the container:

$ docker build --rm -t cyclops:dev -f Dockerfile.dev .

Bootstrap the container:

$ docker run --rm -d --name=cyclops-dev -v $PWD:/opt/cyclops cyclops:dev

Run the container:

$ docker start cyclops-dev

Attach into the container:

$ docker exec -it cyclops-dev bash

Stop container:

$ docker stop cyclops-dev

Remove container:

$ docker rm -f cyclops-dev

Install dependencies and run tests (after start of container and login into it):

$ cd /opt/cyclops
$ pip install -e . -e .[mysql] -e .[tests]
$ CYCLOPS_TEST_DB_USER=sentry CYCLOPS_TEST_DB_PASS=sentry make tests

Comment thread Dockerfile.dev

FROM mysql:5.7

RUN apt-get update && apt-get install -y --no-install-recommends build-essential tcl curl wget vim python2.7 python3.4 python-pip python-dev python3-dev libssl-dev libcurl4-openssl-dev libmysqlclient-dev
Copy link
Copy Markdown

@index0h index0h Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clear apt cache at the end of command

Comment thread Dockerfile.dev

RUN apt-get update && apt-get install -y --no-install-recommends build-essential tcl curl wget vim python2.7 python3.4 python-pip python-dev python3-dev libssl-dev libcurl4-openssl-dev libmysqlclient-dev

RUN mkdir -p /tmp/redis-server
Copy link
Copy Markdown

@index0h index0h Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to make redis build in single RUN instruction. No need to create huge file system layers, which you will not use

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to combine few RUN instructions?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope. Any instructions like RUN, ENV, COPY... create new file system layer

Comment thread Dockerfile.dev
RUN update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
RUN mkdir -p /opt/cyclops

COPY docker/docker-entrypoint-dev.sh /usr/bin/docker-entrypoint.sh
Copy link
Copy Markdown

@index0h index0h Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you any plans to create another files, like docker-entrypoint-prod.sh?

Comment thread Dockerfile.dev
# Instructions:
#
# Build the container:
# $ docker build --rm -t cyclops:dev -f Dockerfile.dev .
Copy link
Copy Markdown

@index0h index0h Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Push and image to docker hub!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related with this PR

mysql -usentry -psentry -e "CREATE DATABASE sentry;"
mysql -usentry -psentry sentry < /opt/cyclops/tests/sentry_db.sql

service mysql stop
Copy link
Copy Markdown

@index0h index0h Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For unification purpose. post install runs once but service mysql start runs on every run. I think that checking that mysql is running each time docker start calls is much worse than stop-start cycle on bootstrap phase.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Comment thread Dockerfile.dev
# Bootstrap the container:
# $ docker run --rm -d --name=cyclops-dev -v $PWD:/opt/cyclops cyclops:dev
# Run the container:
# $ docker start cyclops-dev
Copy link
Copy Markdown

@index0h index0h Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You already have running container. Docker remove it on stop

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, you suggest remove --rm from docker run?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I suggest single flow. If you use --rm - no need to write instructions like start

Comment thread Dockerfile.dev
# Attach into the container:
# $ docker exec -it cyclops-dev bash
# Stop container:
# $ docker stop cyclops-dev
Copy link
Copy Markdown

@index0h index0h Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this and next instructions, you already recommend once-running containers.

Comment thread Dockerfile.dev
#
# NOTE: This should not be used in production!
#
# Instructions:
Copy link
Copy Markdown

@index0h index0h Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This information should be in README or CONTRIBUTING

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point

Comment thread Dockerfile.dev
@@ -0,0 +1,49 @@
# cyclops dev environment
Copy link
Copy Markdown

@index0h index0h Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to move your files to specific directory, for example
docker/work/Dockerfile
docker/work/root/usr/local/bin/docker-entrypoint.sh
docker/work/root/usr/local/bin/post-install.sh

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make no sense for small deployments like this one.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about prod docker file? where it will be stored?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants