-
Notifications
You must be signed in to change notification settings - Fork 15
/
Dockerfile
140 lines (120 loc) · 3.74 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
FROM composer:2.2 AS composer_base
#-----------------------------------------------------------------
FROM alpine:3.20 AS base
#Install packages
RUN apk add --no-cache \
tar \
nginx \
nodejs \
npm \
supervisor \
php82 \
php82-session \
php82-ctype \
php82-fpm \
php82-pdo \
php82-opcache \
php82-zip \
php82-phar \
php82-iconv \
php82-cli \
php82-curl \
php82-openssl \
php82-mbstring \
php82-tokenizer \
php82-fileinfo \
php82-json \
php82-xml \
php82-xmlwriter \
php82-simplexml \
php82-dom \
php82-pdo_mysql \
php82-pdo_pgsql \
php82-tokenizer
RUN ln -s /usr/bin/php82 /usr/bin/php
#-----------------------------------------------------------------
FROM base AS build-container
# Installing composer
COPY --from=composer_base /usr/bin/composer /usr/local/bin/composer
#Configure backend
WORKDIR /var/www/html
COPY back/ .
RUN mv .env.example .env
ENV COMPOSER_ALLOW_SUPERUSER=1
RUN composer install --no-dev --optimize-autoloader
RUN php artisan key:generate
RUN tar --owner=www-data --group=www-data --exclude=.git -czf /tmp/app-back.tar.gz .
#Configure frontend
WORKDIR /var/www/html/front
COPY front/ .
RUN npm install \
&& npm run build
RUN npm prune --production
RUN npm cache clean --force
RUN tar --owner=www-data --group=www-data \
--exclude=.git \
--exclude=.nuxt \
--exclude=.cache \
--exclude=node_modules/eslint-plugin-vue \
--exclude=node_modules/esbuild \
--exclude=node_modules/date-fns \
--exclude=node_modules/csso \
--exclude=node_modules/node-gyp \
--exclude=node_modules/vite \
--exclude=node_modules/@npmcli \
--exclude=node_modules/caniuse-lite \
--exclude=node_modules/vite-plugin-inspect \
--exclude=node_modules/@eslint \
--exclude=node_modules/lodash \
--exclude=node_modules/nuxi \
--exclude=node_modules/@unocss \
--exclude=node_modules/eslint* \
--exclude=node_modules/@rollup \
--exclude=node_modules/prettier \
--exclude=node_modules/@esbuild \
--exclude=node_modules/workbox-build \
--exclude=node_modules/es-abstract \
--exclude=node_modules/shiki \
--exclude=node_modules/@nuxt \
--exclude=node_modules/@typescript-eslint \
--exclude=node_modules/@vue/devtools* \
--exclude=node_modules/vant \
--exclude=node_modules/mathjs \
--exclude=node_modules/typescript \
--exclude=node_modules/@faker-js \
--exclude=node_modules/@opentelemetry \
node_modules/@babel/parser \
--exclude=node_modules/@babel \
--exclude=node_modules/@tabler \
-czf /tmp/app-front.tar.gz .
#-----------------------------------------------------------------
FROM base
WORKDIR /var/www/html
RUN --mount=type=bind,from=build-container,source=/tmp/,target=/build \
tar -xf /build/app-back.tar.gz -C .
WORKDIR /var/www/html/front
RUN --mount=type=bind,from=build-container,source=/tmp/,target=/build \
tar -xf /build/app-front.tar.gz -C .
RUN adduser \
--disabled-password \
--gecos "" \
--home "$(pwd)" \
--ingroup www-data \
--no-create-home \
www-data
RUN mkdir -p -m 772 /tmp/nginx/ && chown -R www-data:www-data /tmp/nginx
RUN chmod -R 772 /var/www/html/storage && chown -R www-data:www-data /var/www/html/storage
# Configure supervisor
COPY docker/conf/supervisor/supervisord.conf /etc/supervisord.conf
COPY docker/conf/supervisor/ /etc/supervisor.d/
# Configure PHP
RUN mkdir -p /run/php/ && touch /run/php/php8.2-fpm.pid
COPY docker/conf/php-fpm/ /etc/php82/
# Configure nginx
COPY docker/conf/nginx/ /etc/nginx/
# Configure entrypoint
COPY --chmod=755 docker/docker-entrypoint.d/ /docker-entrypoint.d/
#set default db connection
ENV DB_CONNECTION=sqlite
ENTRYPOINT ["/docker-entrypoint.d/start.sh"]
CMD ["run"]