Deploy Laravel on the Lightsail Container

Seobs
2 min readJan 15, 2021

In November 2020, Lightsail container article was posted on the AWS blog.

Lightsail Containers: An Easy Way to Run your Containers in the Cloud

So I deploy laravel using Lightsail Container

Laravel Install

Install Laravel using composer.

composer create-project laravel/laravel idiotlabs-playtencd idiotlabs-playtenphp artisan serve

Create Dockerfile

FROM php:7.4-fpm# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
libzip-dev \
zip \
unzip
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntlRUN curl -sS https://getcomposer.org/installer | php — — install-dir=/usr/local/bin — filename=composerWORKDIR /app
COPY . /app
RUN composer installEXPOSE 8000CMD php artisan serve — host=0.0.0.0 — port=8000

After create Dockerfile, build and run check.

If you see the Laravel main page in your browser, that’s good.

docker build -t idiotlabs-playten .docker run -it --rm -p 8000:8000 idiotlabs-playten

Docker Hub

Push to Docker Hub for use in lightsail.

docker tag idiotlabs-playten cobnut/idiotlabs-playtendocker logindocker push cobnut/idiotlabs-playten

Lightsail

First, create container service.

And create deployment setting.

Set the container name, image, port and public endpoint.

Wait a few moments for the deployment to complete.
After that, you can view the page through the public domain.

--

--