-
Notifications
You must be signed in to change notification settings - Fork 72
Refactor Dockerfile and add some dependencies #44
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
Open
andrewnicols
wants to merge
7
commits into
moodlehq:7.1-stretch
Choose a base branch
from
andrewnicols:71_stretch_local_ci
base: 7.1-stretch
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ef93d70
Add Docker and Git ignore files
andrewnicols 4166928
Refactor installation for better caching
andrewnicols fccc39f
Add docker-entrypoint-initdb
andrewnicols 02c0386
Add NVM to the image
andrewnicols 5144ff9
Clean up after OCI8 install
andrewnicols 96d8438
Add Git
andrewnicols 29c8425
Wait for apache to start
andrewnicols File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.git/* | ||
# Swap files (vim) | ||
[._]*.s[a-v][a-z] | ||
[._]*.sw[a-p] | ||
[._]s[a-rt-v][a-z] | ||
[._]ss[a-gi-z] | ||
[._]sw[a-p] | ||
# Temporary files including undo | ||
*~ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Swap files (vim) | ||
[._]*.s[a-v][a-z] | ||
[._]*.sw[a-p] | ||
[._]s[a-rt-v][a-z] | ||
[._]ss[a-gi-z] | ||
[._]sw[a-p] | ||
# Temporary files including undo | ||
*~ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,32 @@ | ||
FROM php:7.1-apache-stretch | ||
|
||
ADD root/ / | ||
# Fix the original permissions of /tmp, the PHP default upload tmp dir. | ||
RUN chmod 777 /tmp && chmod +t /tmp | ||
|
||
# Setup the required extensions. | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
RUN /tmp/setup/php-extensions.sh | ||
RUN /tmp/setup/oci8-extension.sh | ||
|
||
# Install NVM and the current (as of 26/02/2019) LTS version of Node. | ||
ENV NVM_DIR /usr/local/nvm | ||
ENV NODE_VERSION lts/carbon | ||
RUN mkdir -p $NVM_DIR && \ | ||
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash && \ | ||
. $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && nvm use --delete-prefix $NODE_VERSION | ||
|
||
# Install the standard PHP extensions. | ||
ADD root/tmp/setup/php-extensions.sh /tmp/setup/ | ||
RUN chmod 777 /tmp && chmod +t /tmp && \ | ||
/tmp/setup/php-extensions.sh | ||
ADD nvm-wrapper /usr/local/bin/nvm | ||
|
||
# Install the PHP MSSQL Extension. | ||
ADD root/tmp/setup/mssql-extension.sh /tmp/setup/ | ||
RUN chmod 777 /tmp && chmod +t /tmp && \ | ||
/tmp/setup/mssql-extension.sh | ||
|
||
# Install the PHP OCI8 Extension. | ||
ENV LD_LIBRARY_PATH /usr/local/instantclient | ||
ADD root/tmp/setup/oci8-extension.sh /tmp/setup/ | ||
RUN chmod 777 /tmp && chmod +t /tmp && \ | ||
/tmp/setup/oci8-extension.sh | ||
|
||
RUN mkdir /var/www/moodledata && chown www-data /var/www/moodledata && \ | ||
mkdir /var/www/phpunitdata && chown www-data /var/www/phpunitdata && \ | ||
mkdir /var/www/behatdata && chown www-data /var/www/behatdata && \ | ||
mkdir /var/www/behatfaildumps && chown www-data /var/www/behatfaildumps | ||
# Set the custom entrypoint. | ||
ADD moodle-php-entrypoint /usr/local/bin/ | ||
ENTRYPOINT ["moodle-php-entrypoint"] | ||
andrewnicols marked this conversation as resolved.
Show resolved
Hide resolved
|
||
CMD ["apache2-foreground"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env bash | ||
set -Eeo pipefail | ||
|
||
ARGS="$@" | ||
|
||
# Create directories for general usage. | ||
mkdir /var/www/moodledata && chown www-data:www-data /var/www/moodledata | ||
mkdir /var/www/phpunitdata && chown www-data:www-data /var/www/phpunitdata | ||
mkdir /var/www/behatdata && chown www-data:www-data /var/www/behatdata | ||
mkdir /var/www/behatfaildumps && chown www-data:www-data /var/www/behatfaildumps | ||
|
||
# Ensure that all users get NVM as standard. | ||
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> /etc/bash.bashrc | ||
echo 'export NODE_REPL_HISTORY=' >> /etc/bash.bashrc | ||
mkdir /var/www/.config && chown www-data:www-data /var/www/.config | ||
|
||
# Ensure that the requested version of node is installed. | ||
source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && nvm use --delete-prefix $NODE_VERSION | ||
echo 'nvm use "$NODE_VERSION"' >> /etc/bash.bashrc | ||
|
||
# Load any additional entrypoint init files. | ||
for f in /docker-entrypoint-initdb.d/*; do | ||
case "$f" in | ||
*.sh) | ||
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 | ||
# https://github.com/docker-library/postgres/pull/452 | ||
if [ -x "$f" ]; then | ||
echo "$0: running $f" | ||
"$f" | ||
else | ||
echo "$0: sourcing $f" | ||
. "$f" | ||
fi | ||
;; | ||
*) echo "$0: ignoring $f" ;; | ||
esac | ||
echo | ||
done | ||
|
||
# Execute the original entrypoint with the original args. | ||
exec docker-php-entrypoint $ARGS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
set -Eeo pipefail | ||
|
||
# This is a wrapper around NVM to load the nvm functions, and then run nvm. | ||
|
||
if [ -z "$(LC_ALL=C type -t nvm)" ] || [ "$(LC_ALL=C type -t nvm)" != function ] | ||
then | ||
# The `nvm` variable does not exist, or is not a function. | ||
# Source nvm.sh to load it. | ||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" | ||
fi | ||
|
||
nvm $@ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
BUILD_PACKAGES="gnupg unixodbc-dev" | ||
|
||
apt-get update | ||
apt-get install -y --no-install-recommends apt-transport-https \ | ||
$BUILD_PACKAGES | ||
|
||
# Install Microsoft dependcies for sqlsrv. | ||
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - | ||
curl https://packages.microsoft.com/config/debian/9/prod.list -o /etc/apt/sources.list.d/mssql-release.list | ||
apt-get update | ||
ACCEPT_EULA=Y apt-get install -y msodbcsql17 | ||
|
||
pecl install sqlsrv | ||
docker-php-ext-enable sqlsrv | ||
|
||
# Keep our image size down.. | ||
pecl clear-cache | ||
apt-get remove --purge -y $BUILD_PACKAGES | ||
apt-get autoremove -y | ||
apt-get clean | ||
rm -rf /var/lib/apt/lists/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.