Answer the question
In order to leave comments, you need to log in
Are there any best practices on how to organize web project files with docker?
Here, let's say there is a site without docker:
/helloworld
/app
/public
/config
/vendor
...
/helloworld
/app
/public
/config
/vendor
/docker
/build
/mysql
...
docker-compose.yml
/app
/app
/public
/config
/vendor
...
/build
/mysql
docker-compose.yml
Answer the question
In order to leave comments, you need to log in
It's not so simple, comrade ;)
Following the best practices, you should make a separate repository with a description of the infrastructure of your project.
In total, in your group of projects on GitLab (or in an organization on GitHub) you should get something like the following:
/project-group (organization):
/api - сюда можно вынести api вашего проекта.
/desktop - здесь ваш web-проект для desktop на php, например.
/mobile - здесь ваш web-проект для мобильной версии сайта, на той-же node.js.
/admin - здесь ваша админка.
/infrastructure - ну, или назовите проще, "server". Здесь ваши Dockerfile, docker-compose, ci/cd скрипты и т.п.
/infrastructure
/api
service.yml
build.yml
deploy.yml
/mobile
service.yml
build.yml
deploy.yml
/desktop
service.yml
build.yml
deploy.yml
/admin
service.yml
build.yml
deploy.yml
/mysql
mysql.cnf
service.yml
/redis
redis.conf
service.yml
/php-fpm
Dockerfile
www-conf
php.ini
service.yml
/nginx
nginx.conf
/prod
site.conf
/test
site.conf
/dev
site.conf
/cron
Dockerfile
crontab
service.yml
mobile-dev.sh
desktop-dev.sh
prod.sh
test.sh
docker-compose -f mobile/service.yml pull;
docker-compose -f mobile/service.yml down;
docker-compose -f mobile/service.yml up --detach;
version: "3.7"
services:
mobile:
image: keymetrics/pm2:10-alpine
environment:
APP_ENV: ${APP_ENV}
APP_LANG: ${APP_LANG}
API_URL: ${API_URL}
BASIC_TOKEN: ${BASIC_TOKEN}
working_dir: /app
command: pm2-runtime start config.js --env $APP_ENV
volumes:
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
- ${APP_DIR}:/app
restart: always
container_name: mobile
Turnip content:
In the dockerfile, you prescribe the assembly of the project and mounting the build through multi-stage build , so as not to drag npm/php-composer and so on into the image that you will deploy. Dockerfile example:
FROM: build_image as builder
COPY . /src/app
CD /src/app
RUN "build --output /src/app/build"
FROM: deploy_image
COPY --from=builder /src/app/build /app
WORKDIR /app
//дальше запуск приложения как обычно
/project1:
/bin
/www
/src (здесь сервисы, контроллеры и тд)
/docker
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question