8000 update configuration docker · JAVI-CC/Laravel-API-Server@214bf81 · GitHub
[go: up one dir, main page]

Skip to content

Commit 214bf81

Browse files
committed
update configuration docker
1 parent f0b238a commit 214bf81

18 files changed

+113
-8364
lines changed

.dockerignore

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.git
2+
.gitignore
3+
.gitattributes
4+
README.md
5+
/.phpunit.cache
6+
/node_modules
7+
/public/build
8+
/public/hot
9+
/public/storage
10+
/storage/*.key
11+
/vendor
12+
.env
13+
.env.backup
14+
.env.production
15+
.env.prod.*
16+
.phpunit.result.cache
17+
Homestead.json
18+
Homestead.yaml
19+
auth.json
20+
npm-debug.log
21+
yarn-error.log
22+
/.fleet
23+
/.idea
24+
/.vscode
25+
/database/data/additionals/*
26+
/public/css
27+
/public/fonts
28+
/public/js
29+
/public/assets
30+
/public/images
31+
/public/icons
32+
/public/*.ico
33+
/public/index.html
34+
/public/.well-known
35+
*.lock

.env.example

+12-6
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ APP_URL=http://localhost
77
LOG_CHANNEL=stack
88

99
DB_CONNECTION=mysql
10-
DB_HOST=db
10+
DB_HOST=laravel-server-juegos-api-db
1111
DB_PORT=3306
12-
DB_DATABASE=api
13-
DB_USERNAME=user
12+
DB_DATABASE=laravel-juegos
13+
DB_USERNAME=root
1414
DB_PASSWORD=12345678
1515

1616
DB_TEST_CONNECTION=mysql
17-
DB_TEST_HOST=db
17+
DB_TEST_HOST=laravel-server-juegos-api-db
1818
DB_TEST_PORT=3306
19-
DB_TEST_DATABASE=api-test
20-
DB_TEST_USERNAME=user
19+
DB_TEST_DATABASE=laravel-juegos-test
20+
DB_TEST_USERNAME=root
2121
DB_TEST_PASSWORD=12345678
2222

2323
BROADCAST_DRIVER=log
@@ -51,3 +51,9 @@ PUSHER_APP_CLUSTER=mt1
5151

5252
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
5353
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
54+
55+
DROPBOX_AUTH_TOKEN=
56+
57+
L5_SWAGGER_GENERATE_ALWAYS=true
58+
SWAGGER_VERSION=3.0
59+
L5_SWAGGER_CONST_HOST=localhost:8000

Dockerfile

+22-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
FROM php:8.0.6-fpm
1+
FROM php:8.2.13-fpm
22

33
# Arguments defined in docker-compose.yml
44
ARG user
55
ARG uid
66

7+
# Copy composer.json to /var/www/
8+
COPY composer.json /var/www/
9+
10+
# Set working directory
11+
WORKDIR /var/www
12+
713
# Install system dependencies
814
RUN apt-get update && apt-get install -y \
915
git \
@@ -21,16 +27,23 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/*
2127
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd
2228

2329
# Get latest Composer
24-
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
30+
COPY --from=composer:2.7.2 /usr/bin/composer /usr/bin/composer
31+
32+
# We install composer dependencies
33+
RUN composer install --no-ansi --no-interaction --no-progress --optimize-autoloader --no-scripts
34+
35+
# We copy all the files from the current folder of
36+
# laravel files to /var/www/
37+
COPY . .
38+
39+
# To generate the necessary files that Composer will use for autoloading
40+
RUN composer dump-autoload -o
2541

2642
# Create system user to run Composer and Artisan Commands
2743
RUN useradd -G www-data,root -u $uid -d /home/$user $user
2844
RUN mkdir -p /home/$user/.composer && \
2945
chown -R $user:$user /home/$user
3046

31-
# Set working directory
32-
WORKDIR /var/www
33-
3447
RUN apt-get update && apt-get install -y \
3548
libfreetype6-dev \
3649
libjpeg62-turbo-dev \
@@ -39,3 +52,7 @@ RUN apt-get update && apt-get install -y \
3952
&& docker-php-ext-install -j$(nproc) gd
4053

4154
USER $user
55+
56+
EXPOSE 9000
57+
58+
CMD ["php-fpm"]

README.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -234,25 +234,30 @@
234234
<h4>Containers:</h4>
235235
<ul>
236236
<li><span>nginx:alpine</span> - <code>:8000->80/tcp</code></li>
237-
<li><span>mariadb:latest</span> - <code>:3306</code></li>
237+
<li><span>mariadb:11.2.2</span> - <code>:3306</code></li>
238238
<li><span>php:8.0.6-fpm</span> - <code>:9000</code></li>
239239
</ul>
240240

241241
<h4>Containers structure:</h4>
242-
<div class="highlight highlight-source-shell"><pre>├── laravel-api-server-app
243-
├── laravel-api-server-web
244-
└── laravel-api-server-db</pre></div>
242+
<div class="highlight highlight-source-shell"><pre>├── laravel-server-juegos-api-app
243+
├── laravel-server-juegos-api-nginx
244+
└── laravel-server-juegos-api-db</pre></div>
245245

246246
<h4>Setup:</h4>
247247
<pre>
248248
<code>$ git clone https://github.com/JAVI-CC/Laravel-API-Server.git
249249
$ cd Laravel-API-Server
250250
$ cp .env.example .env
251251
$ docker-compose up -d
252-
$ docker-compose exec --user=root app chmod -R 777 /var/www/
253-
$ docker-compose exec app composer install
254252
$ docker-compose exec app php artisan key:generate
255-
$ docker-compose exec app php artisan migrate --seed</code>
253+
$ docker-compose exec app php artisan migrate --seed
254+
$ docker-compose exec app php artisan test</code>
256255
</pre>
257256

257+
<br>
258+
259+
<p>In case you are using your IDE to develop the application and it odes not detect the files it contains within the <strong>vendor folder</strong>, you have to copy the files from the vendor folder of the container to the host machine with the following command.</p>
260+
261+
<pre><code>$ docker compose cp app:/var/www/vendor .</code></pre>
262+
258263
<span>Once you have the containers deployed, you can access the API at </span> <a href="http://localhost:8000" target="_blank">http://localhost:8000</a>

composer.json

+4-6
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@
3535
},
3636
"autoload": {
3737
"psr-4": {
38-
"App\\": "app/"
39-
},
40-
"classmap": [
41-
"database/seeds",
42-
"database/factories"
43-
]
38+
"App\\": "app/",
39+
"Database\\Factories\\": "database/factories/",
40+
"Database\\Seeders\\": "database/seeders/"
41+
}
4442
},
4543
"autoload-dev": {
4644
"psr-4": {

0 commit comments

Comments
 (0)
0