1. Build a simple image.
This is in order to skip this step. This manual premises that you want everything containerized.
FROM php:8.4
COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY --from=node:slim /usr/local/bin /usr/local/bin
COPY --from=node:slim /usr/local/lib/node_modules /usr/local/lib/node_modules
ENV PATH="/root/.composer/vendor/bin:$PATH"
RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get install zip unzip git -y && \
composer global require laravel/installer
docker build -t laravel-installer:12 .
2. Use the image to initiate the project.
cd my-projects/
docker run --rm -it -v "$(pwd):/app" -w /app laravel-installer:12 laravel new foobar
3. Configure.
cd foobar/
vi .env
# if you need to set up app port or DB connections, do it now
# otherwise there would be config caches, which made me pull my hair
APP_URL=http://localhost:8029
APP_PORT=8029
4. Install and activate Laravel Sail.
# your location: my-projects/foobar/ of "host"
docker run --rm -it -v "$(pwd):/app" -w /app laravel-installer:12 bash
# your location: /app inside the container
composer require laravel/sail --dev
php artisan sail:install --devcontainer
5. Start in devcontainer
Open the project in a devcontainer.
Inside the devcontainer, spin up dev server.
composer run dev
If you hate VS Code or any other devcontainer compatible IDEs, you can try the hard way.
sail up -d
sail composer run dev
That's all folks!
Top comments (0)