Setup
I'm running Docker on my Ubuntu server and I'm trying create a Laravel container to run my website with artisan. The Laravel project is inside a GitHub Repository and I clone the project to the docker container with a dockerfile.
Problem
Laravel projects are dependent on the .env
(environment files) which are not included in the repo project, for security reasons. So when I clone the repo to the docker container it doesn't include the .env file and thereby doesn't run the website properly. I have an .env
file locally on my Ubuntu that I'm trying to COPY
to the docker container Laravel project folder, ofcourse it doesn't work. This is because it's looking for the directory in the docker container's file structure.
Error
Step 6/11 : COPY /containers/.env .env
lstat containers/.env: no such file or directory
Question
How can I copy the .env file from the ubuntu server to the docker container with the COPY
command?
file structure (Ubuntu) source from:
root/
containers/
- docker-compose
- .env
file structure (docker container) source to:
root/
var/www/
dockerfile
FROM hitalos/laravel
RUN git config --system http.sslverify false
RUN git clone repo /var/www
RUN git checkout test
COPY /containers/.env .env
# Run Compser Install
RUN composer install -d /var/www
RUN php /var/www/artisan key:generate
WORKDIR /var/www
CMD php /var/www/artisan serve --port=80 --host=0.0.0.0
EXPOSE 80