fix this thing, but db error on startup
This commit is contained in:
parent
367397f39c
commit
2e272eb147
13 changed files with 5 additions and 2 deletions
44
docker/Dockerfile
Normal file
44
docker/Dockerfile
Normal file
|
@ -0,0 +1,44 @@
|
|||
# Dockerfile for the laravel.io application
|
||||
|
||||
FROM ubuntu:22.04
|
||||
|
||||
ARG SEED_DATA="false"
|
||||
|
||||
RUN apt update
|
||||
# install system dependencies
|
||||
RUN apt install software-properties-common git -y
|
||||
|
||||
RUN git clone https://github.com/laravelio/laravel.io.git /app/laravel
|
||||
|
||||
WORKDIR /app/laravel
|
||||
|
||||
RUN mv .env.example .env
|
||||
|
||||
# add php apt repo
|
||||
RUN add-apt-repository ppa:ondrej/php
|
||||
|
||||
RUN apt update
|
||||
|
||||
# install app dependencies
|
||||
RUN DEBIAN_FRONTEND=noninteractive TZ=Europe/Lisbon apt install php8.2 php8.2-simplexml php8.2-curl php8.2-dom composer npm -y
|
||||
|
||||
ENV DB_CONNECTION=mysql
|
||||
ENV DB_HOST=laraveldb
|
||||
ENV DB_DATABASE=laravel
|
||||
ENV DB_USERNAME=myuser
|
||||
ENV DB_PASSWORD=password
|
||||
|
||||
RUN composer install
|
||||
|
||||
RUN php artisan key:generate
|
||||
|
||||
# seed data if build arg is provided
|
||||
RUN if [ "$SEED_DATA" = true ]; then php artisan migrate --seed; fi
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
RUN npm install
|
||||
RUN npm run build
|
||||
|
||||
#Open on port 8000 to all addresses
|
||||
ENTRYPOINT php artisan serve --port=8000 --host=0.0.0.0
|
37
docker/start.sh
Executable file
37
docker/start.sh
Executable file
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
set -x
|
||||
|
||||
# Build image
|
||||
if [ "$(docker network list | grep laravel_net)" == "" ]
|
||||
then
|
||||
docker network create laravel_net
|
||||
fi
|
||||
|
||||
|
||||
if [ "$(docker container list | grep laraveldb)" == "" ]
|
||||
then
|
||||
docker run --name laraveldb --net laravel_net -p 3306:3306 -d \
|
||||
-e MYSQL_USER=myuser \
|
||||
-e MYSQL_PASSWORD=password \
|
||||
-e MYSQL_DATABASE=laravel \
|
||||
-e MYSQL_ALLOW_EMPTY_PASSWORD=true \
|
||||
mysql:latest
|
||||
fi
|
||||
|
||||
# only build image if it doesn't exist
|
||||
if [ "$(docker image list | grep laravelio)" == "" ]
|
||||
then
|
||||
docker build . -t laravelio
|
||||
fi
|
||||
|
||||
docker run --name laravel --net laravel_net -p 80:8000 -d \
|
||||
-e DB_CONNECTION=mysql \
|
||||
-e DB_HOST=laraveldb \
|
||||
-e DB_DATABASE=laravel \
|
||||
-e DB_USERNAME=myuser \
|
||||
-e DB_PASSWORD=password \
|
||||
laravelio
|
||||
|
||||
curl --write-out '%{http_code}' --silent http://localhost:80/ --output output.html
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue