Why the docker container not picking the source code changes

Hi Experts,

     docker container is not picking the recent changes from the source code.     it makes me to build the docker image every time to see the latest changes on the source code.

Please find below the contents of the Dockerfile

FROM ubuntu:16.04

MAINTAINER *****

RUN apt-get update -y
RUN apt-get install -y software-properties-common python-software-properties curl
RUN add-apt-repository -y ppa:fkrull/deadsnakes

RUN apt-get update -y && apt-get install -y curl
RUN apt-get update -y && apt-get install -y \
	git \
	python3.6 \
	python3.6-dev \
	nginx \
	sqlite3 \
	nodejs \
	build-essential \
	libmagickwand-dev \
	cron \
	nginx

RUN rm -f /usr/bin/python3
RUN ln -s /usr/bin/python3.6 /usr/bin/python3
RUN curl https://bootstrap.pypa.io/get-pip.py | python3

WORKDIR /home/trove
COPY . .

COPY build/docker/uwsgi_params .
COPY build/docker/uwsgi.ini .
RUN pip3 install --no-cache-dir uwsgi
RUN pip3 install --no-cache-dir -r requirements.txt

COPY build/docker/start /usr/bin/
COPY build/docker/crontab /etc/cron.d/harvest-cron
RUN chmod 0644 /etc/cron.d/harvest-cron
RUN touch /var/log/harvest.log

RUN echo "daemon off;" >> /etc/nginx/nginx.conf
COPY build/docker/nginx-app.conf /etc/nginx/sites-available/default
COPY build/docker/start /usr/bin/
RUN mkdir /var/log/harvest/
RUN python3 manage.py collectstatic --noinput

WORKDIR /home/trove/
RUN chmod 755 /home/trove
RUN chown -R www-data:www-data /home/trove

EXPOSE 80
CMD ["start"]

Open in new window


please find below the contents of the crontab

SHELL=/bin/bash
* * * * * root ( source /tmp/environment.sh && /usr/bin/python3 /home/trove/run.py $(cat /tmp/method) ) >> /dev/null 2>/var/log/harvest/ts_errors.log

Open in new window


the commands I use in putty shell is

docker build -t harvest-trove:1.0.3 .

for building the image.

then I log into aws cli,

aws configure && $(aws ecr get-login --no-include-email --region ap-southeast-2)
  Access Key ID: ************
  Secret: **************
  ap-southeast-2

Then I tag the docker images to

docker tag harvest-trove:1.0.3 940233033813.dkr.ecr.ap-southeast-2.amazonaws.com/harvest-trove:1.0.3

then push the image

docker push 940233033813.dkr.ecr.ap-southeast-2.amazonaws.com/harvest-trove:1.0.3

create environment variables

declare -a trove_environment=(-e ELASTICSEARCH="[\"http://172.17.0.1\"]" -e STATIC_PATH='/trove/static/' -e CLOUD_WATCH=true -e SCRIPT_NAME=/trove -e AWS_ACCESS_KEY_ID=***********  -e "AWS_SECRET_ACCESS_KEY=**************"  -e AWS_DEFAULT_REGION=ap-southeast-2 -e PRODUCTION=true -e "DATABASE=postgres://trove:******@0.0.0.0/trove" -e "TROVE_KEY=*********" -e "SECONDS_BETWEEN_HARVESTING=72000" -e "ITEMS_PER_FETCH=20" -e "EXIT_AFTER_X_SECONDS=300"  -e "ELASTICSEARCH_INDEX=ntdl" -e "TROVE_API_BASE_URL=http://api.trove.nla.gov.au/result" -e "TERRITORY_STORIES_URL=territorystories.nt.gov.au" -e "HARVEST_PREFIX_URL=trove" -e "S3_BUCKET=*****" -e "S3_SITEMAP_PATH=sitemap" -e "SECONDS_BETWEEN_SITEMAPS=86400" -e "LOCAL_URL_PREFIX=https://ntl-ntdl-dev10.s3.amazonaws.com")

docker run ${trove_environment[@]} -ti 940233033813.dkr.ecr.ap-southeast-2.amazonaws.com/harvest-trove:1.0.3 python3.6 manage.py migrate

docker run --name trove_pull ${trove_environment[@]} -d --restart always 940233033813.dkr.ecr.ap-southeast-2.amazonaws.com/harvest-trove:1.0.3 start pull

docker run --name trove_process ${trove_environment[@]} -d --restart always 940233033813.dkr.ecr.ap-southeast-2.amazonaws.com/harvest-trove:1.0.3 start process

I got the above steps from the documentation which we have already which are used in the demo machine.

I want to create a development environment, are the steps are right for the development environment

My questions are

a) It makes me to build  the docker image every time to see the latest changes.  is there any way I make changes in the source code it gets picked up by the container and it reflects it every time when I run the container.  

b) why I have tag the built image.

c) Why I have to login to aws and push the image to aws.

d) in the following command

docker run --name trove_pull ${trove_environment[@]} -d --restart always 940233033813.dkr.ecr.ap-southeast-2.amazonaws.com/harvest-trove:1.0.3 start pull

where from the following id

940233033813.dkr.ecr.ap-southeast-2.amazonaws.com/harvest-trove:1.0.3  is picked?  how they arrive at this id?

This is id I tag the image and push the image to aws.

All these steps are done at the demo machine.  I am trying to do this above steps on the development machine to make the development environment.

Please clarify my doubts and throw some light over it.

With many thanks,

Bharath AK
LVL 1
Bharath A.KAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Prabhin MPEngineer-TechOPSCommented:
can you put the source code in shared folder from host to docker container.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bharath A.KAuthor Commented:
Hi Prabin,

        The source code is not opensource,  I can't share the source code.  Basically it fetches information from trove through Api's and it stores information to database, and elasticsearch and s3 on aws.   We create many instances of the same application, with many command line options like fetch, process and push to elasticsearch.  The application is executed on crontab it works for few seconds then it stops and starts with the help of crontab.

with many thanks

Bharath AK
0
Bharath A.KAuthor Commented:
Hi Prabhin,

          Sorry for the confusion, I misunderstood what you had said.

With Many thanks,
Bharath AK
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PostgreSQL

From novice to tech pro — start learning today.