Skip to content

Commit 7791793

Browse files
committed
Add docker-compose for production
1 parent 597dcc5 commit 7791793

File tree

13 files changed

+130
-97
lines changed

13 files changed

+130
-97
lines changed

.dockerignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
11
vendor
22
node_modules
3+
public/css
4+
public/js
5+
6+
.git
7+
bootstrap/cache/*
8+
9+
storage/app
10+
storage/logs
11+
storage/framework/cache/data
12+
storage/framework/sessions/*
13+
storage/framework/testing
14+
15+
## if you are using debugbar
16+
storage/debugbar

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"workbench.colorCustomizations": {
3+
"activityBar.background": "#382C02",
4+
"titleBar.activeBackground": "#4E3E03",
5+
"titleBar.activeForeground": "#FEFAEA"
6+
}
7+
}

Dockerfile renamed to Dockerfile.dev

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ RUN composer install
3232

3333
RUN php artisan key:generate --ansi
3434

35+
RUN php artisan storage:link
36+
3537
COPY ./script/php_script.sh /tmp
3638

3739
RUN chmod +x /tmp/php_script.sh

Dockerfile.node

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ RUN npm install
88

99
COPY . .
1010

11-
CMD npm run watch -- --watch-poll
11+
CMD npm run watch -- --watch-poll

Dockerfile.prod

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#Client App
2+
FROM node:14.15.0 as vuejs
3+
4+
LABEL authors="Nimat Razmjo"
5+
6+
RUN mkdir -p /app/public
7+
8+
COPY package.json webpack.mix.js package-lock.json /app/
9+
COPY resources/ /app/resources/
10+
11+
WORKDIR /app
12+
13+
RUN npm install && npm run prod
14+
15+
16+
#Server Dependencies
17+
FROM composer:2.0.8 as vendor
18+
19+
WORKDIR /app
20+
21+
COPY database/ database/
22+
23+
COPY composer.json composer.json
24+
COPY composer.lock composer.lock
25+
26+
RUN composer install \
27+
--ignore-platform-reqs \
28+
--no-interaction \
29+
--no-plugins \
30+
--no-scripts \
31+
--prefer-dist
32+
33+
#Final Image
34+
FROM php:7.4-apache as base
35+
#install php dependencies
36+
RUN apt-get update && apt-get install -y \
37+
build-essential \
38+
libpng-dev \
39+
libonig-dev \
40+
libjpeg62-turbo-dev \
41+
libfreetype6-dev \
42+
locales \
43+
libzip-dev \
44+
zip \
45+
jpegoptim optipng pngquant gifsicle \
46+
unzip \
47+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
48+
49+
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl
50+
51+
# change the document root to /var/www/html/public
52+
RUN sed -i -e "s/html/html\/public/g" \
53+
/etc/apache2/sites-enabled/000-default.conf
54+
55+
# enable apache mod_rewrite
56+
RUN a2enmod rewrite
57+
58+
WORKDIR /var/www/html
59+
60+
COPY . /var/www/html
61+
COPY --from=vendor /app/vendor/ /var/www/html/vendor/
62+
COPY --from=vuejs /app/public/js/ /var/www/html/public/js/
63+
COPY --from=vuejs /app/public/css/ /var/www/html/public/css/
64+
COPY --from=vuejs /app/mix-manifest.json /var/www/html/mix-manifest.json
65+
66+
RUN pwd && ls -la
67+
68+
RUN php artisan key:generate --ansi && php artisan storage:link && php artisan config:cache && php artisan route:cache
69+
70+
71+
# these directories need to be writable by Apache
72+
RUN chown -R www-data:www-data /var/www/html/storage \
73+
/var/www/html/bootstrap/cache
74+
75+
# copy env file for our Docker image
76+
# COPY env.docker /var/www/html/.env
77+
78+
# create sqlite db structure
79+
RUN mkdir -p storage/app \
80+
&& touch storage/app/db.sqlite
81+
82+
VOLUME ["/var/www/html/storage", "/var/www/html/bootstrap/cache"]
83+
84+
EXPOSE 80

Dockerfile.production

Lines changed: 0 additions & 75 deletions
This file was deleted.

docker-compose.production.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@ services:
33
server:
44
build:
55
context: .
6-
dockerfile: Dockerfile.production
6+
dockerfile: Dockerfile.prod
77
target: base
88
container_name: server
99
env_file:
1010
- ./.env
11-
ports:
12-
- "${HTTP_PORT}:8000"
13-
volumes:
14-
- ./:/var/www/
15-
- /var/www/vendor
1611
depends_on:
1712
- mysql
1813
links:
1914
- mysql
15+
ports:
16+
- 80:80
17+
networks:
18+
- back-tier
2019
mysql:
2120
image: mysql
2221
container_name: mysql
@@ -27,9 +26,14 @@ services:
2726
MYSQL_USER: ${DB_USERNAME}
2827
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
2928
ports:
30-
- ${MYSQL_PORT}:3306
29+
- ${MYSQL_PORT}:3306
3130
volumes:
3231
- ./mysql/init.sql:/data/application/init.sql
3332
- mysql_data:/var/lib/mysql
33+
networks:
34+
- back-tier
35+
3436
volumes:
3537
mysql_data:
38+
networks:
39+
back-tier:

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ services:
3636
- ./:/var/www/
3737
- /var/www/node_modules
3838
depends_on:
39-
- 'server'
39+
- "server"
4040
volumes:
4141
mysql_data5:

nginx/conf.d

Whitespace-only changes.

resources/js/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ const app = new Vue({
1919
el: '#app',
2020
router: router,
2121
render: h => h(App),
22-
});
22+
});

0 commit comments

Comments
 (0)