Skip to content

Commit adf6579

Browse files
committed
install composer in Laravel image and remove composer service
install composer in Laravel image instead use composer in independent service for better compatibility
1 parent b61ecce commit adf6579

File tree

5 files changed

+11
-21
lines changed

5 files changed

+11
-21
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ DB_PASSWORD=password
3232
```
3333

3434
- step 5: change other env variable if you need and run `docker compose up -d`
35-
- step 6: run `docker compose exec -it -u 1000 composer composer install --ignore-platform-reqs`
35+
- step 6: run `docker compose exec -it -u 1000 laravel composer install`
3636
- step 7: run `docker compose exec -it -u 1000 laravel php artisan key:generate`
3737
- step 8: run `docker compose exec -it -u 1000 laravel php artisan migrate`
3838
- step 9: open [localhost](http://localhost) to see laravel welcome page

docker-compose-common.yml

-9
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@ services:
2020
# # command: tail -f /dev/null
2121
# command: npm run dev -- --host
2222

23-
composer:
24-
container_name: "${APP_NAME}-composer"
25-
build: "./mnr_docker/composer"
26-
image: "mnr-laravel-11/composer"
27-
restart: unless-stopped
28-
working_dir: /project
29-
volumes:
30-
- ".:/project"
31-
3223
mysql:
3324
container_name: "${APP_NAME}-mysql"
3425
build: "./mnr_docker/mysql"

docker-compose-prd.yml

-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ services:
1818
# # command: npm run dev -- --host
1919
# command: tail -f /dev/null
2020

21-
composer:
22-
extends:
23-
file: docker-compose-common.yml
24-
service: composer
25-
2621
mysql:
2722
extends:
2823
file: docker-compose-common.yml

docker-compose.yml

-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ services:
88
depends_on:
99
- mysql
1010
- redis
11-
- composer
1211

1312
#
1413
# node:
@@ -21,11 +20,6 @@ services:
2120
# command: npm run dev -- --host
2221
# command: tail -f /dev/null
2322

24-
composer:
25-
extends:
26-
file: docker-compose-common.yml
27-
service: composer
28-
2923
mysql:
3024
extends:
3125
file: docker-compose-common.yml

mnr_docker/php/8.3/dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ ENV USERNAME www-data
1010

1111
RUN apt-get update -y && apt-get install -y cron supervisor
1212

13+
#install composer
14+
RUN curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
15+
RUN HASH=`curl -sS https://composer.github.io/installer.sig`
16+
RUN php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
17+
RUN php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
18+
1319
#install packages for working with images. libraries like https://image.intervention.io/ need this.
1420
RUN apt-get install -y libpng-dev libjpeg-dev libwebp-dev libfreetype6-dev libjpeg62-turbo-dev
1521
RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp
@@ -46,6 +52,10 @@ RUN mkdir -p /var/www/.config/psysh
4652
RUN chmod -R 755 /var/www/.config
4753
RUN chown -R www-data:www-data /var/www/.config
4854

55+
RUN mkdir -p /var/www/.composer
56+
RUN chmod -R 755 /var/www/.composer
57+
RUN chown -R www-data:www-data /var/www/.composer
58+
4959
# you can add php config 👇
5060
# RUN echo "memory_limit = 2048M" > $PHP_INI_DIR/conf.d/config.ini
5161

0 commit comments

Comments
 (0)