Another start script to run multiple processes in the same docker container

master
Tudor Stanciu 2020-04-15 01:09:23 +03:00
parent 0c43f28cdc
commit 7f86c057f9
3 changed files with 25 additions and 7 deletions

View File

@ -24,8 +24,8 @@ COPY --from=builder /app/start/api.sh ./application/api/
RUN chmod +x application/api/api.sh
RUN printf '\n\n- Copy application starting script\n'
COPY --from=builder /app/start/start.sh ./application/
RUN chmod +x application/start.sh
COPY --from=builder /app/start/start2.sh ./application/
RUN chmod +x application/start2.sh
#install static server || Alternativ se poate utiliza si http-server
RUN npm install -g serve
@ -38,7 +38,7 @@ WORKDIR /application
EXPOSE 80 3001
CMD ["./start.sh"]
CMD ["./start2.sh"]
#CMD ["sh", "-c", "node application/api/createMockDb.js && node application/api/apiServer.js && serve -s application/front -p 80"]
#CMD ["serve", "-s", "build", "-p", "80"]

View File

@ -1,18 +1,18 @@
#!/bin/bash
# Start the first process and put it in the background
./front/front.sh -D &
./api/api.sh -D &
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start front: $status"
echo "Failed to start api: $status"
exit $status
fi
# Start the second process
./api/api.sh -D
./front/front.sh -D
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start api: $status"
echo "Failed to start front: $status"
exit $status
fi

18
start/start2.sh Normal file
View File

@ -0,0 +1,18 @@
#!/bin/bash
# turn on bash's job control
set -m
# Start the primary process and put it in the background
./front/front.sh &
# Start the helper process
./api/api.sh
# the my_helper_process might need to know how to wait on the
# primary process to start before it does its work and returns
# now we bring the primary process back into the foreground
# and leave it there
fg %1