From 1d2776289abe313b10c49d627f3219f5066c3b1a Mon Sep 17 00:00:00 2001 From: Tanel Tammik Date: Sat, 23 Oct 2021 23:49:52 +0300 Subject: [PATCH] wip --- .gitignore | 2 +- bin/build | 2 -- bin/env | 9 --------- bin/root | 2 -- bin/start | 2 -- bin/stop | 2 -- bin/user | 2 -- config/docker.env | 7 ------- docker-compose.yml | 4 +--- env.example | 9 +++++++++ readme.md | 4 +++- 11 files changed, 14 insertions(+), 31 deletions(-) delete mode 100755 bin/env delete mode 100644 config/docker.env create mode 100644 env.example diff --git a/.gitignore b/.gitignore index c6ef218..de03f38 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ .idea - +.env diff --git a/bin/build b/bin/build index 3db3d59..d0790a1 100755 --- a/bin/build +++ b/bin/build @@ -2,6 +2,4 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd ) -source $DIR/env - docker-compose -f $DIR/../docker-compose.yml up --build diff --git a/bin/env b/bin/env deleted file mode 100755 index facbc56..0000000 --- a/bin/env +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd ) - -source $DIR/../config/docker.env - -if [ -f $DIR/../../docker.env ]; then - source $DIR/../../docker.env -fi diff --git a/bin/root b/bin/root index fbfa697..f1c1847 100755 --- a/bin/root +++ b/bin/root @@ -2,6 +2,4 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd ) -source $DIR/env - docker exec -it --user root -w /root ${DOCKER_APP_CONTAINER} bash diff --git a/bin/start b/bin/start index 6c4eec9..f20840e 100755 --- a/bin/start +++ b/bin/start @@ -2,6 +2,4 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd ) -source $DIR/env - docker-compose -f $DIR/../docker-compose.yml up -d diff --git a/bin/stop b/bin/stop index 44233d9..9194775 100755 --- a/bin/stop +++ b/bin/stop @@ -2,6 +2,4 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd ) -source $DIR/env - docker-compose -f $DIR/../docker-compose.yml down diff --git a/bin/user b/bin/user index 570de13..f0c333a 100755 --- a/bin/user +++ b/bin/user @@ -2,6 +2,4 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd ) -source $DIR/env - docker exec -it --user ${DOCKER_APP_USERNAME} -w /var/www/html ${DOCKER_APP_CONTAINER} bash diff --git a/config/docker.env b/config/docker.env deleted file mode 100644 index 4032e18..0000000 --- a/config/docker.env +++ /dev/null @@ -1,7 +0,0 @@ -export DOCKER_APP_NAME=app -export DOCKER_APP_CONTAINER=apache-8-0-${DOCKER_APP_NAME} -export DOCKER_APP_UID=$UID -export DOCKER_APP_GID=$GID -export DOCKER_APP_USERNAME=$USER -export DOCKER_APP_HOSTNAME=app.localhost -export DOCKER_APP_DOCROOT=public diff --git a/docker-compose.yml b/docker-compose.yml index 4fd00da..d597d37 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ services: web: container_name: ${DOCKER_APP_CONTAINER} restart: always + env_file: ./.env build: context: ./config dockerfile: apache.dockerfile @@ -22,9 +23,6 @@ services: - ./..:/var/www/html - $HOME/.ssh:/home/user/.ssh - ./home:/home/user - environment: - - APACHE_RUN_USER=#${DOCKER_APP_UID} - - APACHE_RUN_GROUP=#${DOCKER_APP_UID} mariadb: container_name: mariadb-10-4-${DOCKER_APP_NAME} restart: always diff --git a/env.example b/env.example new file mode 100644 index 0000000..66d9353 --- /dev/null +++ b/env.example @@ -0,0 +1,9 @@ +DOCKER_APP_NAME=app +DOCKER_APP_CONTAINER=apache-8-0-${DOCKER_APP_NAME} +DOCKER_APP_UID=1000 +DOCKER_APP_GID=1000 +DOCKER_APP_USERNAME=user +DOCKER_APP_HOSTNAME=app.localhost +DOCKER_APP_DOCROOT=public +APACHE_RUN_USER=#${DOCKER_APP_UID} +APACHE_RUN_GROUP=#${DOCKER_APP_UID} diff --git a/readme.md b/readme.md index 7aff6fd..fdff8fb 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,8 @@ # Docker setup for php development (WIP) -Put this repository into your project root and copy config/docker.env to your project root and make changes as needed. +Put this repository into your project root and copy `env.example` to `.env` and make changes as needed. + +You should match UID,GIT,USERNAME to your host machine. ``` └── project_root