-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.staging
111 lines (78 loc) · 3.57 KB
/
Dockerfile.staging
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
#######################################################################
# Laravel/Lumen 5.8 Application - Dockerfile v0.5 #
#######################################################################
#------------- Setup Environment -------------------------------------------------------------
# Pull base image
FROM ubuntu:18.04
# Install common tools
RUN apt-get update \
&& apt-get install -y wget curl vim nano inetutils-ping htop git unzip bzip2 software-properties-common locales jq
# Install SSH
RUN apt-get update \
&& apt-get install -y openssh-server \
&& mkdir -p /var/run/sshd
# Set evn var to enable xterm terminal
ENV TERM=xterm
# Set timezone to UTC to avoid tzdata interactive mode during build
ENV TZ=Etc/UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Set working directory
WORKDIR /var/www/html
# Set up locales
# RUN locale-gen
#------------- Application Specific Stuff ----------------------------------------------------
# Install PHP
RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
RUN apt update && apt-get install -y \
php7.4-fpm \
php7.4-common \
php7.4-curl \
php7.4-mysql \
php7.4-mbstring \
php7.4-json \
php7.4-xml \
php7.4-bcmath
# Install NPM and Node.js
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs
#------------- FPM & Nginx configuration ----------------------------------------------------
# Config fpm to use TCP instead of unix socket
ADD resources/www.conf /etc/php/7.4/fpm/pool.d/www.conf
RUN mkdir -p /var/run/php
# Install Nginx
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ABF5BD827BD9BF62
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C
RUN echo "deb http://nginx.org/packages/ubuntu/ trusty nginx" >> /etc/apt/sources.list
RUN echo "deb-src http://nginx.org/packages/ubuntu/ trusty nginx" >> /etc/apt/sources.list
RUN apt-get update && apt-get install -y nginx
ADD resources/default /etc/nginx/sites-enabled/
ADD resources/nginx.conf /etc/nginx/
#------------- Composer & laravel configuration ----------------------------------------------------
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
#------------- Supervisor Process Manager ----------------------------------------------------
# Install supervisor
RUN apt-get install -y supervisor
RUN mkdir -p /var/log/supervisor
ADD resources/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# ------------- Add a startup script ----------------------------------------------------
COPY migrate-db.sh /usr/local/bin/migrate-db.sh
RUN chmod +x /usr/local/bin/migrate-db.sh
#------------- Container Config ---------------------------------------------------------------
# Expose port 22 & 80
EXPOSE 22 80
# Set supervisor to manage container processes
ENTRYPOINT ["/usr/bin/supervisord"]
#------------- Container Config - Extras for non local environment -------------------------
# Bundle web service source
COPY src /var/www/html
# Install app dependencies
RUN cd /var/www/html && \
composer install --no-interaction
#------------- Container Config - Aliasing the nginx logs to stdout and stderr--------------
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
#------------- Container Config - Ownership & Log and cache folders writable --------------
RUN chown -R www-data:www-data /var/www/html/
RUN chmod -R 755 /var/www/html/storage
RUN chmod -R 755 /var/www/html/bootstrap/cache || echo ""