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
8
8
9
9
## Configuration
10
10
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
26
12
27
13
``` 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 "
29
15
```
30
16
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.
32
20
33
21
``` shell
34
- php artisan vendor:publish --provider=" BlameButton\LaravelDockerBuilder\DockerServiceProvider"
22
+ DOCKER_NGINX_TAG=laravel-app:nginx
23
+ DOCKER_PHP_TAG=laravel-app:php
35
24
```
36
25
37
26
## Usage
38
27
39
- Set the ` DOCKER_NGINX_TAG ` and ` DOCKER_PHP_TAG ` environment variables and run:
40
-
41
28
``` shell
42
- vendor/bin/ docker- build
29
+ php artisan docker: build
43
30
```
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
3
- source .env
4
-
5
3
PACKAGE=" $( dirname " ${BASH_SOURCE[0]} " ) /.."
6
4
7
5
if ! [[ -f " ${PWD} /public/index.php" ]]; then
@@ -14,6 +12,18 @@ if ! [[ -f "${PWD}/.dockerignore" ]]; then
14
12
cp " ${PACKAGE} /docker/.dockerignore" " ${PWD} /.dockerignore"
15
13
fi
16
14
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
+
17
27
NGINX_TAG=" ${DOCKER_NGINX_TAG} "
18
28
PHP_TAG=" ${DOCKER_PHP_TAG} "
19
29
@@ -27,13 +37,11 @@ if [[ -z "${PHP_TAG}" ]]; then
27
37
exit 1
28
38
fi
29
39
30
- echo " Building [${NGINX_TAG} ]"
31
40
docker build \
32
41
--tag " ${NGINX_TAG} " \
33
42
--file " ${PWD} /.docker/nginx.dockerfile" \
34
43
" ${PWD} "
35
44
36
- echo " Building [${PHP_TAG} ]"
37
45
docker build \
38
46
--tag " ${PHP_TAG} " \
39
47
--file " ${PWD} /.docker/php.dockerfile" \
Original file line number Diff line number Diff line change 9
9
"email" : " bram@ceulemans.dev"
10
10
}
11
11
],
12
- "bin" : [
13
- " bin/docker-build"
14
- ],
15
12
"require" : {
16
13
"php" : " ^8.0" ,
17
14
"illuminate/contracts" : " ^9.47" ,
File renamed without changes.
Original file line number Diff line number Diff line change 2
2
3
3
namespace BlameButton \LaravelDockerBuilder \Commands ;
4
4
5
- use BlameButton \LaravelDockerBuilder \DockerServiceProvider ;
6
5
use Symfony \Component \Process \Process ;
7
6
8
7
class DockerBuildCommand extends BaseCommand
@@ -16,6 +15,10 @@ public function handle(): int
16
15
$ process = new Process (
17
16
command: [$ command ],
18
17
cwd: base_path (),
18
+ env: [
19
+ 'DOCKER_NGINX_TAG ' => config ('docker-builder.tags.nginx ' ),
20
+ 'DOCKER_PHP_TAG ' => config ('docker-builder.tags.php ' ),
21
+ ],
19
22
);
20
23
21
24
$ process ->run (function ($ type , $ buffer ) {
Original file line number Diff line number Diff line change @@ -18,11 +18,11 @@ public function boot(): void
18
18
}
19
19
20
20
$ this ->publishes ([
21
- __DIR__ . '/../config/docker-build .php ' => config_path ('docker-build .php ' ),
21
+ __DIR__ . '/../config/docker-builder .php ' => config_path ('docker-builder .php ' ),
22
22
]);
23
23
24
24
$ this ->mergeConfigFrom (
25
- __DIR__ . '/../config/docker-build .php ' , 'docker-builder ' ,
25
+ __DIR__ . '/../config/docker-builder .php ' , 'docker-builder ' ,
26
26
);
27
27
}
28
28
You can’t perform that action at this time.
0 commit comments