Add application file
Browse files- Dockerfile +26 -21
- init-db.sh +20 -0
Dockerfile
CHANGED
@@ -18,6 +18,7 @@ RUN apt-get update && apt-get install -y \
|
|
18 |
git \
|
19 |
zlib1g-dev \
|
20 |
libxslt-dev \
|
|
|
21 |
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
22 |
&& docker-php-ext-install gd zip pdo pdo_mysql mysqli \
|
23 |
&& pecl install xdebug-3.0.4 \
|
@@ -28,38 +29,42 @@ RUN apt-get update && apt-get install -y \
|
|
28 |
# Install Composer
|
29 |
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
30 |
|
|
|
|
|
|
|
|
|
31 |
# Set the working directory
|
32 |
WORKDIR /var/www
|
33 |
|
34 |
# Copy application files
|
35 |
-
COPY . /var/www
|
36 |
-
|
37 |
-
# Ensure .env.example exists and create .env if missing
|
38 |
-
# RUN if [ -f .env.example ]; then cp .env.example .env; else echo ".env.example file not found"; exit 1; fi
|
39 |
-
|
40 |
-
RUN ls
|
41 |
-
|
42 |
-
RUN composer create-project bagisto/bagisto
|
43 |
|
44 |
-
RUN cd bagisto
|
45 |
-
|
46 |
-
RUN ls
|
47 |
-
WORKDIR /var/www/bagisto
|
48 |
-
RUN ls
|
49 |
# Install Bagisto dependencies
|
50 |
-
RUN composer install
|
51 |
|
52 |
# Generate application key
|
53 |
-
RUN php artisan key:generate
|
54 |
|
55 |
-
#
|
56 |
-
RUN
|
57 |
-
RUN php artisan migrate
|
58 |
-
RUN php artisan db:seed
|
59 |
-
RUN php artisan vendor:publish --all
|
60 |
-
RUN php artisan storage:link
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
# Expose port 7860
|
65 |
EXPOSE 7860
|
|
|
18 |
git \
|
19 |
zlib1g-dev \
|
20 |
libxslt-dev \
|
21 |
+
mysql-server \
|
22 |
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
23 |
&& docker-php-ext-install gd zip pdo pdo_mysql mysqli \
|
24 |
&& pecl install xdebug-3.0.4 \
|
|
|
29 |
# Install Composer
|
30 |
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
31 |
|
32 |
+
# Copy the custom initialization script
|
33 |
+
COPY init-db.sh /usr/local/bin/init-db.sh
|
34 |
+
RUN chmod +x /usr/local/bin/init-db.sh
|
35 |
+
|
36 |
# Set the working directory
|
37 |
WORKDIR /var/www
|
38 |
|
39 |
# Copy application files
|
40 |
+
COPY . /var/www/bagisto
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
|
|
|
|
|
|
|
|
|
|
42 |
# Install Bagisto dependencies
|
43 |
+
RUN cd bagisto && composer install
|
44 |
|
45 |
# Generate application key
|
46 |
+
RUN cd bagisto && php artisan key:generate
|
47 |
|
48 |
+
# Ensure .env.example exists and create .env if missing
|
49 |
+
RUN cd bagisto && [ -f .env.example ] && cp .env.example .env || (echo ".env.example file not found" && exit 1)
|
|
|
|
|
|
|
|
|
50 |
|
51 |
+
# Set environment variables for Bagisto
|
52 |
+
ENV DB_CONNECTION=mysql \
|
53 |
+
DB_HOST=127.0.0.1 \
|
54 |
+
DB_PORT=3306 \
|
55 |
+
DB_DATABASE=bagisto \
|
56 |
+
DB_USERNAME=bagisto \
|
57 |
+
DB_PASSWORD=bagisto
|
58 |
|
59 |
+
# Initialize MySQL database
|
60 |
+
RUN /usr/local/bin/init-db.sh
|
61 |
+
|
62 |
+
# Run Bagisto installation
|
63 |
+
RUN cd bagisto && php artisan bagisto:install
|
64 |
+
RUN cd bagisto && php artisan migrate
|
65 |
+
RUN cd bagisto && php artisan db:seed
|
66 |
+
RUN cd bagisto && php artisan vendor:publish --all
|
67 |
+
RUN cd bagisto && php artisan storage:link
|
68 |
|
69 |
# Expose port 7860
|
70 |
EXPOSE 7860
|
init-db.sh
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
set -e
|
3 |
+
|
4 |
+
# Start MySQL service
|
5 |
+
service mysql start
|
6 |
+
|
7 |
+
# Wait for MySQL to be available
|
8 |
+
sleep 10
|
9 |
+
|
10 |
+
# Create the database and user
|
11 |
+
mysql -u root -proot -e "CREATE DATABASE IF NOT EXISTS bagisto;"
|
12 |
+
mysql -u root -proot -e "CREATE USER 'bagisto'@'%' IDENTIFIED BY 'bagisto';"
|
13 |
+
mysql -u root -proot -e "GRANT ALL PRIVILEGES ON bagisto.* TO 'bagisto'@'%';"
|
14 |
+
mysql -u root -proot -e "FLUSH PRIVILEGES;"
|
15 |
+
|
16 |
+
# Stop MySQL service
|
17 |
+
service mysql stop
|
18 |
+
|
19 |
+
# Start the main process
|
20 |
+
exec "$@"
|