File tree Expand file tree Collapse file tree 6 files changed +26
-31
lines changed
Expand file tree Collapse file tree 6 files changed +26
-31
lines changed Original file line number Diff line number Diff line change @@ -8,36 +8,23 @@ composer require --dev blamebutton/laravel-docker-builder
88
99## Configuration
1010
11- Two environment variables need to be set:
12-
13- * ` DOCKER_NGINX_TAG `
14- * ` DOCKER_PHP_TAG `
15-
16- This can be done either by adding them to your ` .env ` file or passing them to the build command.
17-
18- ### Option 1: ` .env `
19-
20- ```
21- DOCKER_NGINX_TAG=laravel-app:nginx
22- DOCKER_PHP_TAG=laravel-app:php
23- ```
24-
25- ### Option 2: CLI
11+ ### Option 1: Config File
2612
2713``` shell
28- DOCKER_NGINX_TAG=laravel-app:nginx DOCKER_PHP_TAG=laravel-app: php vendor/bin/docker-build
14+ php artisan vendor:publish --provider= " BlameButton\LaravelDockerBuilder\DockerServiceProvider "
2915```
3016
31- ### Option 3: Config File
17+ ### Option 2: ` .env `
18+
19+ By default, the configuration file reads the following environment variables to determine the Docker image tags.
3220
3321``` shell
34- php artisan vendor:publish --provider=" BlameButton\LaravelDockerBuilder\DockerServiceProvider"
22+ DOCKER_NGINX_TAG=laravel-app:nginx
23+ DOCKER_PHP_TAG=laravel-app:php
3524```
3625
3726## Usage
3827
39- Set the ` DOCKER_NGINX_TAG ` and ` DOCKER_PHP_TAG ` environment variables and run:
40-
4128``` shell
42- vendor/bin/ docker- build
29+ php artisan docker: build
4330```
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22
3- source .env
4-
53PACKAGE=" $( dirname " ${BASH_SOURCE[0]} " ) /.."
64
75if ! [[ -f " ${PWD} /public/index.php" ]]; then
@@ -14,6 +12,18 @@ if ! [[ -f "${PWD}/.dockerignore" ]]; then
1412 cp " ${PACKAGE} /docker/.dockerignore" " ${PWD} /.dockerignore"
1513fi
1614
15+ if ! [[ -f " $PWD /.docker/nginx.dockerfile" ]]; then
16+ echo " Dockerfile [/.docker/nginx.dockerfile] not found."
17+ echo " Run: php artisan docker:generate"
18+ exit 1
19+ fi
20+
21+ if ! [[ -f " $PWD /.docker/php.dockerfile" ]]; then
22+ echo " Dockerfile [/.docker/php.dockerfile] not found."
23+ echo " Run: php artisan docker:generate"
24+ exit 1
25+ fi
26+
1727NGINX_TAG=" ${DOCKER_NGINX_TAG} "
1828PHP_TAG=" ${DOCKER_PHP_TAG} "
1929
@@ -27,13 +37,11 @@ if [[ -z "${PHP_TAG}" ]]; then
2737 exit 1
2838fi
2939
30- echo " Building [${NGINX_TAG} ]"
3140docker build \
3241 --tag " ${NGINX_TAG} " \
3342 --file " ${PWD} /.docker/nginx.dockerfile" \
3443 " ${PWD} "
3544
36- echo " Building [${PHP_TAG} ]"
3745docker build \
3846 --tag " ${PHP_TAG} " \
3947 --file " ${PWD} /.docker/php.dockerfile" \
Original file line number Diff line number Diff line change 99 "email" : " bram@ceulemans.dev"
1010 }
1111 ],
12- "bin" : [
13- " bin/docker-build"
14- ],
1512 "require" : {
1613 "php" : " ^8.0" ,
1714 "illuminate/contracts" : " ^9.47" ,
File renamed without changes.
Original file line number Diff line number Diff line change 22
33namespace BlameButton \LaravelDockerBuilder \Commands ;
44
5- use BlameButton \LaravelDockerBuilder \DockerServiceProvider ;
65use Symfony \Component \Process \Process ;
76
87class DockerBuildCommand extends BaseCommand
@@ -16,6 +15,10 @@ public function handle(): int
1615 $ process = new Process (
1716 command: [$ command ],
1817 cwd: base_path (),
18+ env: [
19+ 'DOCKER_NGINX_TAG ' => config ('docker-builder.tags.nginx ' ),
20+ 'DOCKER_PHP_TAG ' => config ('docker-builder.tags.php ' ),
21+ ],
1922 );
2023
2124 $ process ->run (function ($ type , $ buffer ) {
Original file line number Diff line number Diff line change @@ -18,11 +18,11 @@ public function boot(): void
1818 }
1919
2020 $ this ->publishes ([
21- __DIR__ . '/../config/docker-build .php ' => config_path ('docker-build .php ' ),
21+ __DIR__ . '/../config/docker-builder .php ' => config_path ('docker-builder .php ' ),
2222 ]);
2323
2424 $ this ->mergeConfigFrom (
25- __DIR__ . '/../config/docker-build .php ' , 'docker-builder ' ,
25+ __DIR__ . '/../config/docker-builder .php ' , 'docker-builder ' ,
2626 );
2727 }
2828
You can’t perform that action at this time.
0 commit comments