build login-server on docker-compose up in a docker volume so it rebuild only neccessary parts if some c++ files have changed

This commit is contained in:
einhornimmond 2021-03-29 17:47:55 +02:00
parent 1f002f4ed0
commit 0da5279175
3 changed files with 82 additions and 75 deletions

View File

@ -1,63 +1,64 @@
version: "3.4"
services:
########################################################
# FRONTEND #############################################
########################################################
frontend:
image: gradido/frontend:development
build:
target: development
environment:
- NODE_ENV="development"
# - DEBUG=true
- NUXT_BUILD=/tmp/nuxt # avoid file permission issues when `rm -rf .nuxt/`
volumes:
# This makes sure the docker container has its own node modules.
# Therefore it is possible to have a different node version on the host machine
- frontend_node_modules:/app/node_modules
# bind the local folder to the docker to allow live reload
- ./frontend:/app
#########################################################
## LOGIN SERVER #########################################
#########################################################
login-server:
build:
target: login_server_debug
dockerfile: Dockerfile.debug
security_opt:
- seccomp:unconfined
cap_add:
- SYS_PTRACE
volumes:
- ./logs:/var/log/grd_login
- conan:/root/.conan
#########################################################
## NGINX ################################################
#########################################################
nginx:
volumes:
- ./logs:/var/log/nginx
#########################################################
## PHPMYADMIN ###########################################
#########################################################
phpmyadmin:
image: phpmyadmin
container_name: phpmyadmin
environment:
- PMA_ARBITRARY=1
#restart: always
ports:
- 8074:80
networks:
- internal-net
- external-net
volumes:
- /sessions
volumes:
frontend_node_modules:
conan:
version: "3.4"
services:
########################################################
# FRONTEND #############################################
########################################################
frontend:
image: gradido/frontend:development
build:
target: development
environment:
- NODE_ENV="development"
# - DEBUG=true
- NUXT_BUILD=/tmp/nuxt # avoid file permission issues when `rm -rf .nuxt/`
volumes:
# This makes sure the docker container has its own node modules.
# Therefore it is possible to have a different node version on the host machine
- frontend_node_modules:/app/node_modules
# bind the local folder to the docker to allow live reload
- ./frontend:/app
#########################################################
## LOGIN SERVER #########################################
#########################################################
login-server:
build:
target: login_server_debug
dockerfile: Dockerfile.debug
security_opt:
- seccomp:unconfined
cap_add:
- SYS_PTRACE
volumes:
- ./logs:/var/log/grd_login
- ./login_server/src:/code/src
- login_build:/code/build_vol
#########################################################
## NGINX ################################################
#########################################################
nginx:
volumes:
- ./logs:/var/log/nginx
#########################################################
## PHPMYADMIN ###########################################
#########################################################
phpmyadmin:
image: phpmyadmin
container_name: phpmyadmin
environment:
- PMA_ARBITRARY=1
#restart: always
ports:
- 8074:80
networks:
- internal-net
- external-net
volumes:
- /sessions
volumes:
frontend_node_modules:
login_build:

View File

@ -24,8 +24,8 @@ USER root
#COPY --from=debug_preparation /code /code
#COPY --from=debug_preparation /home/conan /home/conan
#RUN ls -la /home/conan/.conan
COPY . .
WORKDIR ${DOCKER_WORKDIR}
COPY . .
#RUN ls -la
#RUN cat build/conanbuildinfo.cmake
@ -34,18 +34,15 @@ RUN chmod +x compile_pot.sh
#RUN ls -la
RUN ./compile_pot.sh
RUN ./compile_proto.sh
RUN cd build && \
cmake -DCMAKE_BUILD_TYPE=Debug .. && \
make -j$(nproc) Gradido_LoginServer
#########################################################################################################
# run debug
#########################################################################################################
FROM ubuntu:latest as login_server_debug
WORKDIR "/usr/bin"
FROM debug as login_server_debug
ENV DOCKER_WORKDIR="/code"
#RUN apt-get update && \
# apt-get install -y --no-install-recommends gdb && \
# apt-get autoclean && \
@ -54,17 +51,17 @@ WORKDIR "/usr/bin"
# rm -rf /var/lib/apt/lists/*
VOLUME /var/log/grd_login
VOLUME /code/src
COPY --from=debug /code/build/bin/Gradido_LoginServer /usr/bin/
COPY --from=debug /code/build/lib/libmariadb.so.3 /usr/lib/
#COPY start_after_mysql.sh .
RUN chmod +x /usr/bin/Gradido_LoginServer
EXPOSE 1200
EXPOSE 1201
WORKDIR ${DOCKER_WORKDIR}
RUN chmod +x ./Dockerfiles/build_and_run.sh
#ENTRYPOINT ["/usr/bin/Gradido_LoginServer"]
# Wait on mariadb to started
#CMD ["sleep 5", "/usr/bin/Gradido_LoginServer"]
#RUN chmod +x ./start_after_mysql.sh
#ENTRYPOINT ["/usr/bin/Gradido_LoginServer"]
#CMD gdb -ex=r Gradido_LoginServer
CMD Gradido_LoginServer
CMD ./Dockerfiles/build_and_run.sh

View File

@ -0,0 +1,9 @@
#!/bin/bash
cp build/conan* build_vol/
cd build_vol
cmake -DCMAKE_BUILD_TYPE=Debug ..
make -j$(nproc) Gradido_LoginServer
echo "building done"
chmod +x ./bin/Gradido_LoginServer
./bin/Gradido_LoginServer