-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
113 lines (91 loc) · 3.2 KB
/
Dockerfile
File metadata and controls
113 lines (91 loc) · 3.2 KB
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
FROM php:8.2-fpm
# Set working directory
WORKDIR /var/www
# Add docker php ext repo
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
# Install php extensions
RUN chmod +x /usr/local/bin/install-php-extensions && sync && \
install-php-extensions mbstring pdo_mysql zip exif pcntl gd
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
locales \
zip \
jpegoptim optipng pngquant gifsicle \
unzip \
git \
curl \
lua-zlib-dev \
libmemcached-dev \
nginx
# Install supervisor
RUN apt-get install -y supervisor
# Install cron
RUN apt-get install -y cron
COPY ./docker/cronfile /etc/cron.d/cronfile
RUN chmod 0644 /etc/cron.d/cronfile
RUN crontab /etc/cron.d/cronfile
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
#Set Timezone
ARG TZ=Asia/Jakarta
ENV TZ ${TZ}
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Add user for laravel application
RUN groupadd -g 1000 deploy
RUN useradd -u 1000 -ms /bin/bash -g deploy deploy
# Copy code to /var/www
COPY --chown=deploy:deploy . /var/www
# ENV PROD
COPY ./.env.production /var/www/.env
# add root to www group
RUN chmod -R 777 /var/www/storage
# # Copy nginx/php/supervisor configs
RUN cp docker/supervisor.conf /etc/supervisord.conf
RUN cp docker/php.ini /usr/local/etc/php/conf.d/app.ini
RUN cp docker/php-pool.conf /usr/local/etc/php-fpm.d/www.conf
RUN cp docker/nginx.conf /etc/nginx/nginx.conf
RUN cp docker/nginx-site.conf /etc/nginx/sites-enabled/default
# # PHP Error Log Files
RUN mkdir /var/log/php
RUN touch /var/log/php/errors.log && chmod 777 /var/log/php/errors.log
# Deployment steps
RUN composer install --optimize-autoloader --no-dev
RUN php artisan key:generate --force
RUN chmod +x /var/www/docker/run.sh
RUN rm -rf /var/www/html
# Alias
COPY ./docker/aliases.sh /root/aliases.sh
RUN sed -i 's/\r//' /root/aliases.sh && \
echo "" >> ~/.bashrc && \
echo "# Load Custom Aliases" >> ~/.bashrc && \
echo "source ~/aliases.sh" >> ~/.bashrc && \
echo "" >> ~/.bashrc
# Install nodejs
RUN mkdir /root/.nvm
ENV NVM_DIR /root/.nvm
ENV NODE_VERSION node
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install ${NODE_VERSION} \
&& nvm use ${NODE_VERSION} \
&& nvm alias ${NODE_VERSION} \
&& npm cache clear --force \
npm install -g npm-check-updates
RUN echo "" >> ~/.bashrc && \
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bashrc && \
echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> ~/.bashrc
RUN find $NVM_DIR -type f -name node -exec ln -s {} /usr/local/bin/node \; && \
NODE_MODS_DIR="$NVM_DIR/versions/node/$(node -v)/lib/node_modules" && \
ln -s $NODE_MODS_DIR/npm/bin/npm-cli.js /usr/local/bin/npm && \
ln -s $NODE_MODS_DIR/npm/bin/npx-cli.js /usr/local/bin/npx
#build
RUN npm install
RUN npm run build
EXPOSE 80
ENTRYPOINT ["/var/www/docker/run.sh"]