Skip to content

Commit

Permalink
add php-fpm build
Browse files Browse the repository at this point in the history
  • Loading branch information
loic-lopez committed Dec 28, 2018
1 parent 15a2db4 commit 555533c
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 28 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
.idea
venv
*.pem
/**/Dockerfile
nginx/Dockerfile
php-fpm/Dockerfile
laravel-artisan/Dockerfile
12 changes: 6 additions & 6 deletions nginx/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
path = os.path.dirname(os.path.realpath(__file__))


class Directory(Enum):
API = 'exosuite-users-api'
WEBSITE = 'exosuite-website'


class Token(Enum):
CONF = ':conf'
DIR = ':dir'
Expand All @@ -31,11 +36,6 @@ class Domain(Enum):
WEBSITE = 'exosuite.local'


class Directory(Enum):
API = 'exosuite-users-api'
WEBSITE = 'exosuite-website'


def generateCertificates(domain: Domain):
os.system("openssl req -subj '/CN="
+ domain.value + "' -x509 -newkey rsa:4096 -nodes -keyout key.pem -out cert.pem -days 365")
Expand All @@ -44,7 +44,7 @@ def generateCertificates(domain: Domain):
def generateDockerfile(datas):
dockerFileContent = open('./Dockerfile.template').read()

dockerFileContent = dockerFileContent.replace(Token.CONF.value, datas[Token.CONF])\
dockerFileContent = dockerFileContent.replace(Token.CONF.value, datas[Token.CONF]) \
.replace(Token.DIR.value, datas[Token.DIR].value)

f = open("Dockerfile", "w")
Expand Down
6 changes: 3 additions & 3 deletions php-fpm/website/Dockerfile → php-fpm/Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ RUN pecl install -o -f redis \

RUN docker-php-ext-install -j$(nproc) pdo_pgsql pcntl posix bcmath opcache

COPY exosuite-website /var/www/exosuite-website
COPY :dir /var/www/:dir

RUN find /var/www/exosuite-website -type d -exec chown www-data:www-data {} \;
RUN find /var/www/exosuite-website -type f -exec chown www-data:www-data {} \;
RUN find /var/www/:dir -type d -exec chown www-data:www-data {} \;
RUN find /var/www/:dir -type f -exec chown www-data:www-data {} \;

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
18 changes: 0 additions & 18 deletions php-fpm/api/Dockerfile

This file was deleted.

59 changes: 59 additions & 0 deletions php-fpm/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env python3

import optparse
import os
from enum import Enum

path = os.path.dirname(os.path.realpath(__file__))


class Directory(Enum):
API = 'exosuite-users-api'
WEBSITE = 'exosuite-website'


class Token(Enum):
DIR = ':dir'

@staticmethod
def api():
data = dict()
data[Token.DIR] = Directory.API.value
return data

@staticmethod
def website():
data = dict()
data[Token.DIR] = Directory.WEBSITE.value
return data


def generateDockerfile(datas):
dockerFileContent = open('./Dockerfile.template').read()

dockerFileContent = dockerFileContent.replace(Token.DIR.value, datas[Token.DIR])

f = open("Dockerfile", "w")
f.write(dockerFileContent)
f.close()


parser = optparse.OptionParser()
parser.add_option("--website", action="store_true", dest="website")
parser.add_option("--api", action='store_true', dest="api")
parser.add_option("--clean", action='store_true', dest="clean")
(opts, args) = parser.parse_args()

os.chdir(path)

if opts.api:
generateDockerfile(Token.api())
print("Dockerfile generated for API!")
elif opts.website:
generateDockerfile(Token.website())
print("Dockerfile generated for WEBSITE!")
elif opts.clean:
os.system("rm -f Dockerfile")
print("Directory cleaned!")
else:
parser.print_help()

0 comments on commit 555533c

Please sign in to comment.