Skip to content

Commit 4ad436f

Browse files
update to use env file and add auto install script
1 parent c1b4cb0 commit 4ad436f

File tree

6 files changed

+52
-14
lines changed

6 files changed

+52
-14
lines changed

.docker.env.dist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# database env vars
2+
POSTGRES_USER=project
3+
POSTGRES_PASSWORD=project
4+
POSTGRES_DB=project
5+
PGDATA=/var/data
6+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.docker.env

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
# Docker skeleton for PHP projects
1+
# Docker environment skeleton for PHP projects
22

33
This is a Docker skeleton for getting any PHP project up and running and running in a Docker environment.
44

55
## Usage
66

7-
- ```git clone https://github.com/rendler-denis/docker-project-skeleton.git .```
7+
- ```curl -L https://github.com/rendler-denis/docker-project-skeleton/install.bash | bash``` or ```git clone https://github.com/rendler-denis/docker-project-skeleton.git .```
88
- update ```docker-compose.override.yml``` as needed by adding or updating existing services
99
- add any SQL files that might be needed for first time database creation under ```.docker/{dev|prod}/db/scripts/```
10+
- update the domain for Nginx under ```.docker/{dev|prod}/nginx/etc/conf.d/default.conf```
11+
- if any changes to the environment variables is required copy .docker.env.dist to .docker.env and update as required
1012
- run ```docker-compose up -d```
1113

14+
## Features
15+
- fix user permissions when running on linux hosts
16+
- automatically run database scripts on database creation
17+
- PHP's Xdebug automatically added and configured for development
18+
1219
## Services defined
1320

1421
- **Web server**: nginx at latest version

docker-compose.override.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
- ./.docker/dev/php/conf.d/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xxdebug.ini
99
db:
1010
volumes:
11-
- .docker/dev/db/scripts:/docker-entrypoint-initdb.d
11+
- .docker/dev/db/scripts:/docker-entrypoint-initdb.d:ro
1212

1313
nginx:
1414
image: nginx:latest

docker-compose.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,40 @@ services:
99
args:
1010
VERSION: 7.3-fpm
1111
image: project:7.3-fpm
12-
cap_drop:
13-
- ALL
1412
volumes:
1513
- ./:/project
1614
networks:
1715
- project
16+
env_file:
17+
- .docker.env.dist
18+
- .docker.env
1819

1920
db:
2021
image: postgres:latest
2122
volumes:
22-
- db_data:/var/data
23-
- .docker/prod/db/scripts:/docker-entrypoint-initdb.d
23+
- db_data:/var/data:rw
24+
- .docker/prod/db/scripts:/docker-entrypoint-initdb.d:ro
2425
networks:
2526
- project
26-
environment:
27-
POSTGRES_USER: project
28-
POSTGRES_PASSWORD: project
29-
POSTGRES_DB: project
30-
PGDATA: /var/data
3127
ports:
3228
- "5432:5432"
29+
env_file:
30+
- .docker.env.dist
31+
- .docker.env
3332

3433
nginx:
3534
image: nginx:latest
3635
volumes:
3736
- ./:/project
3837
- ./.docker/prod/nginx/etc/conf.d/default.conf:/etc/nginx/conf.d/default.conf
38+
networks:
39+
- project
3940
ports:
4041
- "80:80"
4142
- "443:443"
42-
networks:
43-
- project
43+
env_file:
44+
- .docker.env.dist
45+
- .docker.env
4446

4547
volumes:
4648
db_data: {}

install.bash

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
REPOSITORY="https://github.com/rendler-denis/docker-project-skeleton"
4+
ARTIFACTS_URL="https://api.github.com/repos/rendler-denis/docker-project-skeleton/tarball"
5+
TMPFILE="docker.tar.gz"
6+
7+
function download() {
8+
LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' $REPOSITORY/releases/latest)
9+
LATEST_VERSION=$(echo $LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
10+
TARBALL_URL="$ARTIFACTS_URL/$LATEST_VERSION"
11+
12+
echo "Downloading tag: $LATEST_VERSION \n"
13+
curl -L $TARBALL_URL -o $TMPFILE
14+
}
15+
16+
function unpack() {
17+
echo "Unpacking to local folder... \n"
18+
tar -xvf $TMPFILE --strip 1
19+
}
20+
21+
download
22+
unpack

0 commit comments

Comments
 (0)