elderstar, duch-nuon liked this thread
This is a very interesting topic. I am a complete newbie to docker. I'm also interested in a good way to deploy an existing laravel application developed locally using sail and docker to a production server.
It's also important to be able to easily sync new local files to the production server in the future. I mean rsync on solo or github on a team.
I don't know how to do but my guess is that we will need to create a new docker image by picking out the laravel application from the sail dev environment. Then define the docker images stack we need to create a proper working "prod" environment on the remote server and add a new laravel application image to this stack instead of mounting the application file volumes.
I have read too many different articles and everyone does it in their own way. And I do not have a solid understanding of how to do it in a good way.
Thanks
Here is the way I go from sail to prod. Special thanks to my brother for his help. and thanks to this article The essence is the same as I described above. In fact, what is missing in the Sail environment, but necessary in the production server? We need a more stable web server. I have taken PHP -FPM + NGINX and going to try RR later.
Here is a sail Dockerfile /vendor/laravel/sail/runtimes/8.1/Dockerfile
And here is my new Dockerfile for prod.
FROM php:8.1-fpm
ARG user
ARG uid
RUN apt-get update && apt-get install -y \
git \
curl \
libpq-dev \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
unzip
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-install pdo_pgsql mbstring exif pcntl bcmath gd
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
RUN useradd -G www-data,root -u $uid -d /home/$user $user
RUN mkdir -p /home/$user/.composer &&
chown -R $user:$user /home/$user
WORKDIR /var/www
USER $user
next I copied a docker-compose.yml file and change it:
So now the app runs apart of the sail and I think it is more suitable for a prod. Moved the app to a prod server and run docker compose up --build
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community