Commit 2b621df7 authored by damianofalcioni's avatar damianofalcioni

added initialization script at runtime. Copy operation not needed anymore for persistence

parent 619b6cab
......@@ -6,17 +6,11 @@ Instructions to build and start the microservice-controller container:
1) Build the image
<pre>
sudo docker build --no-cache -f msc-Dockerfile .
sudo docker build -f msc-Dockerfile .
</pre>
2) Enable Persistence
2) Run the container
<pre>
sudo docker create --name app _id_from_build_
mkdir ./msc-data
sudo docker cp app:/opt/msc-data/ ./msc-data/
</pre>
3) Run the container
<pre>
sudo docker run -it -p 8080:8080 -v ${PWD}/msc-data/:/opt/msc-data/ _id_from_build_
</pre>
\ No newline at end of file
#Build:
# sudo docker build --no-cache -f msc-Dockerfile .
#
#Enable Persistence:
# sudo docker create --name app _id_from_build_
# mkdir ./msc-data
# sudo docker cp app:/opt/msc-data/ ./msc-data/
# sudo docker build -f msc-Dockerfile .
#
#Run:
# mkdir ./msc-data
# sudo docker run -it -p 8080:8080 -v ${PWD}/msc-data/:/opt/msc-data/ _id_from_build_
#
#TODO
#- Create a script to move the services configuration at runtime
#
FROM tomcat:8.5-jdk8
# set bash instead of sh as default shell for RUN
......@@ -20,7 +13,8 @@ SHELL ["/bin/bash", "-c"]
# maven setup to compile the sources
RUN \
apt-get -q update && \
apt-get -qy install maven
apt-get -qy install maven && \
apt-get -qy install nano
# MSC compilation, deployment and configuration
ENV msc_data=/opt/msc-data
......@@ -33,14 +27,18 @@ RUN \
tar xzpf /opt/microservice-controller-master.tar.gz -C /opt && \
rm /opt/microservice-controller-master.tar.gz && \
mvn -B -f /opt/microservice-controller-master/pom.xml clean install && \
rm -r /opt/microservice-controller-master
RUN \
wget https://git.boc-group.eu/adoxx/microservice-controller-rest/-/archive/master/microservice-controller-rest-master.tar.gz -O /opt/microservice-controller-rest-master.tar.gz && \
tar xzpf /opt/microservice-controller-rest-master.tar.gz -C /opt && \
rm /opt/microservice-controller-rest-master.tar.gz && \
mvn -B -f /opt/microservice-controller-rest-master/pom.xml clean package && \
unzip /opt/microservice-controller-rest-master/target/micro-service-controller-rest.war -d /usr/local/tomcat/webapps/msc/ && \
rm -r /opt/microservice-controller-rest-master && \
rm -r /opt/microservice-controller-rest-master
RUN \
mkdir ${msc_data} && \
echo '{"microservicesDefinitionFolder":"'${msc_service_dir}'","uploadFolder":"'${msc_upload_dir}'","logFileName":"'${msc_log}'","autostartEnabled":true}' > ${MSC_CONFIG}
echo 'if [ -f "${MSC_CONFIG}" ]; then exit 0; else echo "{\"microservicesDefinitionFolder\":\"${msc_service_dir}\",\"uploadFolder\":\"${msc_upload_dir}\",\"logFileName\":\"${msc_log}\",\"autostartEnabled\":true}" > ${MSC_CONFIG}; fi' > /opt/initialize.sh && \
chmod +x /opt/initialize.sh
# maven cleanup
RUN \
......@@ -48,4 +46,5 @@ RUN \
apt-get -qy autoremove && \
rm -r /root/.m2/
EXPOSE 8080
\ No newline at end of file
EXPOSE 8080
CMD ["bash", "-c", "/opt/initialize.sh && catalina.sh run"]
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment