Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docker): create productionised application dockerfile #25

Merged
merged 51 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
6b80068
Initial draft of dockerfile
rahul-dvsa Feb 27, 2024
2a08dc3
feat: initial code review internal AWS
chris-lorro Feb 27, 2024
4c07656
adding code for php docker extentions configuration
chris-lorro Feb 29, 2024
84a7f28
installing extensions configuration
chris-lorro Mar 4, 2024
0d144c0
updated dockerfile
rahul-dvsa Mar 5, 2024
1616fde
updated .gitignore
rahul-dvsa Mar 5, 2024
2956cab
feature: internal code review and updates
chris-lorro Mar 5, 2024
42d132d
Implemented review comments
rahul-dvsa Mar 5, 2024
d3bbc57
Merge remote-tracking branch 'origin/main' into feat/VOL-4796, gettin…
rahul-dvsa Mar 5, 2024
c4c79fd
Aligned to the directory
rahul-dvsa Mar 5, 2024
1d09e66
doc: comments updated
rahul-dvsa Mar 5, 2024
0265019
opcache max value updated to 20000 based on total php files in project
rahul-dvsa Mar 6, 2024
fd95ee3
Feedback implemented
rahul-dvsa Mar 7, 2024
c4c714c
Updated nginx config with secure headers
rahul-dvsa Mar 7, 2024
03e2b41
removed the overrides config from www.conf file
rahul-dvsa Mar 8, 2024
1a073ba
dockerfile adjusted
rahul-dvsa Mar 10, 2024
b839593
remove duplication from dockerfile
rahul-dvsa Mar 10, 2024
6fd10da
remove duplication from dockerfile
rahul-dvsa Mar 10, 2024
7a21340
feedback implemented
rahul-dvsa Mar 11, 2024
5cda326
dockerfile updated the layer adjusted as icu-dev is required
rahul-dvsa Mar 11, 2024
1e2b183
dockerfile updated with account number
rahul-dvsa Mar 11, 2024
d9f4761
added aws header
rahul-dvsa Mar 12, 2024
21a78a3
Update Dockerfile
rahul-dvsa Mar 20, 2024
5d20288
Update backend.conf
rahul-dvsa Mar 20, 2024
b5913e7
Update php.ini removed aws headers
rahul-dvsa Mar 20, 2024
ef172b7
Introduced package version
rahul-dvsa Mar 25, 2024
213567e
updated dockerfile
rahul-dvsa Mar 26, 2024
3206bf6
updated dockerfile FROM statement
rahul-dvsa Mar 26, 2024
5102458
Merge branch 'main' into feat/VOL-4796
gabrielg2020 Apr 16, 2024
41432bc
feat: using GHCR image not ECR
gabrielg2020 Apr 17, 2024
929ef99
fix: changed way to install redis and igbinary
gabrielg2020 Apr 17, 2024
626849a
feat: installed pdo_mysql, opcahce and intl
gabrielg2020 Apr 17, 2024
ee00e3b
fix: fixed formatting in php.ini
gabrielg2020 Apr 17, 2024
2392ddd
fix: changed where artifact is downloaded
gabrielg2020 Apr 17, 2024
3ae5307
feat: add application code to /var/www/html
gabrielg2020 Apr 17, 2024
359f2fa
fix: need root access to change permissions to app code
gabrielg2020 Apr 17, 2024
ea0f194
fix: changed nginx conf name to api & revert user back to www-data
gabrielg2020 Apr 17, 2024
ba70a97
feat: configured nginx
gabrielg2020 Apr 17, 2024
7d9a9a8
feat: add relevant api security configurations to nginx config
gabrielg2020 Apr 17, 2024
4d1046e
chore: removed backend.conf
gabrielg2020 Apr 17, 2024
e39ef96
fix: composer update in php.yaml
gabrielg2020 Apr 18, 2024
9add96e
fix: removing composer update to see inital error
gabrielg2020 Apr 18, 2024
c746137
refactor: fixed formatting in api.conf
gabrielg2020 Apr 18, 2024
33dcd5a
fix: added versions to apk ADD
gabrielg2020 Apr 18, 2024
3f7f8ce
fix: fixed package version and added quotes
gabrielg2020 Apr 18, 2024
9f4057f
fix: added double quotes across Dockerfile
gabrielg2020 Apr 18, 2024
cea8e35
fix: different formatting to try and fix linting
gabrielg2020 Apr 18, 2024
1862d22
fix: added stable tag to image
gabrielg2020 Apr 18, 2024
48c5c51
fix: less strict version pinning
gabrielg2020 Apr 18, 2024
f0cc1fd
fix: ignore DL3018 & SC2086 linting errors
gabrielg2020 Apr 18, 2024
2491224
Merge branch 'main' into feat/VOL-4796
gabrielg2020 Apr 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion infra/docker/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
FROM php:8.2-fpm
# hadolint global ignore=DL3018,SC2086
FROM ghcr.io/dvsa/dvsa-docker-images/php/7.4/fpm-nginx:0

USER root

# Install redis with igbinary
RUN apk add --no-cache pcre-dev~=8.45 $PHPIZE_DEPS \
&& pecl install igbinary \
&& pecl install -D "enable-redis-igbinary="yes" enable-redis-lzf="no" enable-redis-zstd="no"" redis \
&& docker-php-ext-enable redis igbinary \
&& apk del pcre-dev $PHPIZE_DEPS

RUN apk add --no-cache icu-dev~=71.1 \
&& docker-php-ext-install mysqli pdo_mysql \
&& docker-php-ext-install opcache \
&& docker-php-ext-configure intl && docker-php-ext-install intl \
&& apk del icu-dev

# PHP config file
COPY ./php.ini ${PHP_INI_DIR}/conf.d/1000-php.ini

ADD --chown=www-data ./api.tar.gz /var/www/html

# nginx server config file
COPY api.conf /etc/nginx/conf.d/api.conf

USER www-data
53 changes: 53 additions & 0 deletions infra/docker/api/api.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
server {
listen 80;
listen [::]:80;

server_name _;

root /var/www/html/public;

# Prevent some browsers from MIME-sniffing the response.
#
# This reduces exposure to drive-by download attacks and cross-origin data
# leaks, and should be left uncommented, especially if the server is serving
# user-uploaded content or content that could potentially be treated as
# executable by the browser.
#
# https://owasp.org/www-project-secure-headers/#x-content-type-options
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options
# https://blogs.msdn.microsoft.com/ie/2008/07/02/ie8-security-part-v-comprehensive-protection/
# https://mimesniff.spec.whatwg.org/

add_header X-Content-Type-Options nosniff always;

# Block access to files that can expose sensitive information.
#
# By default, block access to backup and source files that may be left by some
# text editors and can pose a security risk when anyone has access to them.
#
# https://feross.org/cmsploit/
#
# (!) Update the `location` regular expression from below to include any files
# that might end up on your production server and can expose sensitive
# information about your website. These files may include: configuration
# files, files that contain metadata about the project (e.g.: project
# dependencies, build scripts, etc.).

location ~* (?:#.*#|\.(?:bak|conf|dist|fla|in[ci]|log|orig|psd|sh|sql|sw[op])|~)$ {
deny all;
}

location / {
try_files $uri /index.php?q=$uri&$args;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php-fpm.socket;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 600;
fastcgi_index index.php;
include fastcgi_params;
}
}
21 changes: 21 additions & 0 deletions infra/docker/api/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; For more information on the config file, please see:
; https://www.php.net/manual/en/index.php

[opcache]
; The maximum number of keys (and therefore scripts) in the OPcache hash table
; The Allowed value is between 200 and 100000. Recommendation is to have this
; number approximately equal to the total number of php files in your project
; https://programmer.group/php7-enables-opcache-to-create-powerful-performance.html#:~:text=opcache.max_accelerated_files
opcache.max_accelerated_files=20000
JoshuaLicense marked this conversation as resolved.
Show resolved Hide resolved

; Validate timestamps of scripts on each request.
opcache.validate_timestamps=1

; Specifies the frequency at which OPcache checks for changes to PHP scripts
; in the filesystem. The value is in seconds.
opcache.revalidate_freq=60

; Enable the cli
opcache.enable_cli=1