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

View File

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