Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Docker - VirtueMart images
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Tools
Docker - VirtueMart images
Commits
8c5a1a35
Commit
8c5a1a35
authored
9 years ago
by
Reinhold Kainhofer
Browse files
Options
Downloads
Patches
Plain Diff
Use supervisord to (potentially) start mysql and the apache server
parent
fc89f9d8
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
j2vm3_full/Dockerfile
+16
-3
16 additions, 3 deletions
j2vm3_full/Dockerfile
j2vm3_full/docker-entrypoint.sh
+114
-84
114 additions, 84 deletions
j2vm3_full/docker-entrypoint.sh
j2vm3_full/supervisord.conf
+10
-0
10 additions, 0 deletions
j2vm3_full/supervisord.conf
with
140 additions
and
87 deletions
j2vm3_full/Dockerfile
+
16
−
3
View file @
8c5a1a35
...
@@ -4,9 +4,10 @@ MAINTAINER Reinhold Kainhofer <reinhold@kainhofer.com>
...
@@ -4,9 +4,10 @@ MAINTAINER Reinhold Kainhofer <reinhold@kainhofer.com>
# Enable Apache Rewrite Module
# Enable Apache Rewrite Module
RUN
a2enmod rewrite
RUN
a2enmod rewrite
RUN
apt-get update
# Install PHP extensions
# Install PHP extensions
RUN
apt-get
update
&&
apt-get
install
-y
libpng12-dev libjpeg-dev zip unzip
&&
rm
-rf
/var/lib/apt/lists/
*
\
RUN
apt-get
install
-y
libpng12-dev libjpeg-dev zip unzip
\
&&
docker-php-ext-configure gd
--with-png-dir
=
/usr
--with-jpeg-dir
=
/usr
\
&&
docker-php-ext-configure gd
--with-png-dir
=
/usr
--with-jpeg-dir
=
/usr
\
&&
docker-php-ext-install gd
&&
docker-php-ext-install gd
RUN
docker-php-ext-install mysqli
RUN
docker-php-ext-install mysqli
...
@@ -14,7 +15,12 @@ RUN docker-php-ext-install mysqli
...
@@ -14,7 +15,12 @@ RUN docker-php-ext-install mysqli
VOLUME
/var/www/html
VOLUME
/var/www/html
# Install MySQL (will only be started if needed)
# Install MySQL (will only be started if needed)
# RUN apt-get update && apt-get install -y mysql-server && rm -rf /var/lib/apt/lists/*
# RUN export DEBIAN_FRONTEND=noninteractive
RUN
echo
"mysql-server-5.5 mysql-server/root_password password root"
| debconf-set-selections
RUN
echo
"mysql-server-5.5 mysql-server/root_password_again password root"
| debconf-set-selections
RUN
DEBIAN_FRONTEND
=
noninteractive apt-get
install
-y
mysql-server
RUN
apt-get
install
-y
supervisor
# Define Joomla version and expected SHA1 signature
# Define Joomla version and expected SHA1 signature
...
@@ -29,10 +35,17 @@ RUN curl -o virtuemart.zip -SL http://dev.virtuemart.net/attachments/download/98
...
@@ -29,10 +35,17 @@ RUN curl -o virtuemart.zip -SL http://dev.virtuemart.net/attachments/download/98
&&
unzip virtuemart.zip
-d
/usr/src/virtuemart
\
&&
unzip virtuemart.zip
-d
/usr/src/virtuemart
\
&&
rm
virtuemart.zip
\
&&
rm
virtuemart.zip
\
&&
chown
-R
www-data:www-data /usr/src/virtuemart
&&
chown
-R
www-data:www-data /usr/src/virtuemart
RUN
echo
"[program:mysql]
\n
command=/usr/bin/pidproxy /run/mysqld/mysqld.pid /usr/bin/mysqld_safe
\n
autorestart=true
\n
"
>
/etc/supervisor/conf.d/mysql.conf.save
# Clean up the apt cache etc.
RUN
rm
-rf
/var/lib/apt/lists/
*
# Copy init scripts and custom .htaccess
# Copy init scripts and custom .htaccess
COPY
docker-entrypoint.sh /entrypoint.sh
COPY
docker-entrypoint.sh /entrypoint.sh
COPY
makedb.php /makedb.php
COPY
makedb.php /makedb.php
ADD
supervisord.conf /etc/supervisor/supervisord.conf
ENTRYPOINT
["/entrypoint.sh"]
ENTRYPOINT
["/entrypoint.sh"]
CMD
["
apache2-foreground
"]
CMD
["
/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf
"]
This diff is collapsed.
Click to expand it.
j2vm3_full/docker-entrypoint.sh
+
114
−
84
View file @
8c5a1a35
...
@@ -2,102 +2,132 @@
...
@@ -2,102 +2,132 @@
set
-e
set
-e
if
[[
"
$1
"
==
apache2
*
]]
;
then
if
[[
!
-e
"/etc/opentools-docker-configured"
]]
;
then
if
[
-n
"
$MYSQL_PORT_3306_TCP
"
]
;
then
# This docker container has not been configured yet, use the env variables
if
[
-z
"
$JOOMLA_DB_HOST
"
]
;
then
# to set up the MYSQL server or linked container
JOOMLA_DB_HOST
=
'mysql'
else
echo
>
&2
"warning: both JOOMLA_DB_HOST and MYSQL_PORT_3306_TCP found"
echo
>
&2
" Connecting to JOOMLA_DB_HOST (
$JOOMLA_DB_HOST
)"
echo
>
&2
" instead of the linked mysql container"
fi
fi
# If the DB user is 'root' then use the MySQL root password env var
# check if a MYSQL container is linked:
:
${
JOOMLA_DB_USER
:
=root
}
if
[
-n
"
$MYSQL_PORT_3306_TCP
"
]
;
then
if
[
"
$JOOMLA_DB_USER
"
=
'root'
]
;
then
if
[
-z
"
$JOOMLA_DB_HOST
"
]
;
then
:
${
JOOMLA_DB_PASSWORD
:
=
$MYSQL_ENV_MYSQL_ROOT_PASSWORD
}
JOOMLA_DB_HOST
=
'mysql'
fi
else
if
[
-z
"
$JOOMLA_DB_HOST
"
]
;
then
echo
>
&2
"warning: both JOOMLA_DB_HOST and MYSQL_PORT_3306_TCP found"
echo
>
&2
"Neither linked database container nor mysql dabase server host given. "
echo
>
&2
" Connecting to JOOMLA_DB_HOST (
$JOOMLA_DB_HOST
)"
echo
>
&2
" Assuming local installation. An instance of the MySQL server will be installed locally."
echo
>
&2
" instead of the linked mysql container"
MYSQL_LOCAL
=
1
fi
JOOMLA_DB_HOST
=
"127.0.0.1"
fi
if
[
-z
"
${
JOOMLA_DB_PASSWORD
}
"
]
;
then
JOOMLA_DB_PASSWORD
=
'root'
# If the DB user is 'root' and no DB password is given, then use the MySQL root password env var
echo
>
&2
"No MySQL root password given. Assuming password 'root'."
:
${
JOOMLA_DB_USER
:
=root
}
if
[
"
$JOOMLA_DB_USER
"
=
'root'
]
;
then
:
${
JOOMLA_DB_PASSWORD
:
=
$MYSQL_ENV_MYSQL_ROOT_PASSWORD
}
fi
# Check for local MySQL installation:
if
[
-z
"
$JOOMLA_DB_HOST
"
]
;
then
# No linked container and no explicit DB host => local MySQL installation
echo
>
&2
"Neither linked database container nor mysql dabase server host given. "
echo
>
&2
" Assuming local installation. An instance of the MySQL server will be installed locally."
MYSQL_LOCAL
=
1
JOOMLA_DB_HOST
=
"127.0.0.1"
if
[
-z
"
${
JOOMLA_DB_PASSWORD
}
"
]
;
then
JOOMLA_DB_PASSWORD
=
'root'
echo
>
&2
"No MySQL root password given. Assuming password 'root'."
fi
echo
>
&2
" Root password is
${
JOOMLA_DB_PASSWORD
}
."
# Temporarily start the mysql daemon to set up the database and shut it
# down again (supervisord will start it at the very end)
echo
"Starting local mysql server temporarily to set up the database..."
/usr/bin/mysqld_safe
>
/dev/null 2>&1 &
timeout
=
30
echo
-n
"Waiting for database server to accept connections"
while
!
/usr/bin/mysqladmin
--user
=
root
--password
=
root status
>
/dev/null 2>&1
;
do
timeout
=
$((
$timeout
-
1
))
if
[
$timeout
-eq
0
]
;
then
echo
-e
"
\n
Unable to connecto the database server. Aborting..."
exit
1
fi
fi
echo
>
&2
" Root password is
${
JOOMLA_DB_PASSWORD
}
."
echo
-n
"."
sleep
1
export
DEBIAN_FRONTEND
=
noninteractive
done
echo
mysqladmin
--password
=
root password
"
${
JOOMLA_DB_PASSWORD
}
"
# enable mysqld in the supervisor config
cp
/etc/supervisor/conf.d/mysql.conf.save /etc/supervisor/conf.d/mysql.conf
fi
echo
"mysql-server-5.5 mysql-server/root_password password
${
JOOMLA_DB_PASSWORD
}
"
| debconf-set-selections
echo
"mysql-server-5.5 mysql-server/root_password_again password
${
JOOMLA_DB_PASSWORD
}
"
| debconf-set-selections
# Now set up the Database for Joomla/VirtueMart:
# echo 'phpmyadmin phpmyadmin/dbconfig-install boolean true' | debconf-set-selections
:
${
JOOMLA_DB_NAME
:
=virtuemart
}
# echo 'phpmyadmin phpmyadmin/app-password-confirm password ${JOOMLA_DB_PASSWORD}' | debconf-set-selections
# echo 'phpmyadmin phpmyadmin/mysql/admin-pass password ${JOOMLA_DB_PASSWORD}' | debconf-set-selections
# echo 'phpmyadmin phpmyadmin/mysql/app-pass password ${JOOMLA_DB_PASSWORD}' | debconf-set-selections
# echo 'phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2' | debconf-set-selections
dpkg
-s
mysql-server
>
/dev/null 2>&1
||
(
apt-get
-q
update
&&
apt-get
-y
-q
install
mysql-server
&&
rm
-rf
/var/lib/apt/lists/
*
)
# echo >&2 "error: missing JOOMLA_DB_HOST and MYSQL_PORT_3306_TCP environment variables"
# echo >&2 " Did you forget to --link some_mysql_container:mysql or set an external db"
# echo >&2 " with -e JOOMLA_DB_HOST=hostname:port?"
# exit 1
fi
if
[
-n
"
$MYSQL_LOCAL
"
]
;
then
echo
>
&2
"Starting MySQL daemon..."
service mysql restart
fi
:
${
JOOMLA_DB_NAME
:
=virtuemart
}
if
[
-z
"
$JOOMLA_DB_PASSWORD
"
]
;
then
echo
>
&2
"error: missing required JOOMLA_DB_PASSWORD environment variable"
echo
>
&2
" Did you forget to -e JOOMLA_DB_PASSWORD=... or link to a container?"
echo
>
&2
echo
>
&2
" (Also of interest might be JOOMLA_DB_USER and JOOMLA_DB_NAME.)"
exit
1
fi
# Ensure the MySQL Database is created
php /makedb.php
"
$JOOMLA_DB_HOST
"
"
$JOOMLA_DB_USER
"
"
$JOOMLA_DB_PASSWORD
"
"
$JOOMLA_DB_NAME
"
if
[
"
$MYSQL_LOCAL
"
=
"1"
]
;
then
# Local installation, so shut down MySQL again, will later be started through supervisord
/usr/bin/mysqladmin
--user
=
root
--password
=
"
${
JOOMLA_DB_PASSWORD
}
"
shutdown
fi
if
[
-z
"
$JOOMLA_DB_PASSWORD
"
]
;
then
echo
>
&2
"error: missing required JOOMLA_DB_PASSWORD environment variable"
echo
>
&2
" Did you forget to -e JOOMLA_DB_PASSWORD=... ?"
echo
>
&2
echo
>
&2
" (Also of interest might be JOOMLA_DB_USER and JOOMLA_DB_NAME.)"
exit
1
fi
if
!
[
-e
index.php
-a
-e
libraries/cms/version/version.php
]
;
then
# Now set up the Joomla/VirtueMart installation files in apache's directory:
echo
>
&2
"Virtuemart/Joomla not found in
$(
pwd
)
- copying now..."
if
!
[
-e
index.php
-a
-e
libraries/cms/version/version.php
]
;
then
echo
>
&2
"Virtuemart/Joomla not found in
$(
pwd
)
- copying now..."
if
[
"
$(
ls
-A
)
"
]
;
then
if
[
"
$(
ls
-A
)
"
]
;
then
echo
>
&2
"WARNING:
$(
pwd
)
is not empty - press Ctrl+C now if this is an error!"
echo
>
&2
"WARNING:
$(
pwd
)
is not empty - press Ctrl+C now if this is an error!"
(
set
-x
;
ls
-A
;
sleep
10
)
(
set
-x
;
ls
-A
;
sleep
10
)
fi
fi
tar
cf -
--one-file-system
-C
/usr/src/virtuemart
.
|
tar
xf -
tar
cf -
--one-file-system
-C
/usr/src/virtuemart
.
|
tar
xf -
# Some versions of the full installer hae an additional subdir in the ZIP file.
# Search for joomla.xml and mv everything from that directory to the webroot
if
[
!
-e
joomla.xml
]
;
then
for
jmanifest
in
*
/joomla.xml
;
do
jdir
=
$(
dirname
$jmanifest
)
echo
mv
$jdir
/
**
.
rm
-rf
$jdir
done
fi
if
[
!
-e
.htaccess
]
;
then
if
[
-e
htaccess.txt
-a
!
-e
.htaccess
]
;
then
# NOTE: The "Indexes" option is disabled in the php:apache base image so remove it as we enable .htaccess
# NOTE: The "Indexes" option is disabled in the php:apache base image so remove it as we enable .htaccess
sed
-r
's/^(Options -Indexes.*)$/#\1/'
htaccess.txt
>
.htaccess
sed
-r
's/^(Options -Indexes.*)$/#\1/'
htaccess.txt
>
.htaccess
chown
www-data:www-data .htaccess
chown
www-data:www-data .htaccess
fi
fi
sed
's/default="localhost"/default="'
$JOOMLA_DB_HOST
'"/;
s/\(db_user.*\)$/\1 default="'
$JOOMLA_DB_USER
'"/;
s/\(db_pass.*\)$/\1 default="'
$JOOMLA_DB_PASSWORD
'"/;
s/\(db_name.*\)$/\1 default="'
$JOOMLA_DB_NAME
'"/'
installation/models/forms/database.xml
>
installation/models/forms/database.xml.new
mv
installation/models/forms/database.xml.new installation/models/forms/database.xml
echo
>
&2
"Complete! Virtuemart has been successfully copied to
$(
pwd
)
"
sed
's/default="localhost"/default="'
$JOOMLA_DB_HOST
'"/;
fi
s/\(db_user.*\)$/\1 default="'
$JOOMLA_DB_USER
'"/;
s/\(db_pass.*\)$/\1 default="'
$JOOMLA_DB_PASSWORD
'"/;
s/\(db_name.*\)$/\1 default="'
$JOOMLA_DB_NAME
'"/'
installation/models/forms/database.xml
>
installation/models/forms/database.xml.new
mv
installation/models/forms/database.xml.new installation/models/forms/database.xml
# Ensure the MySQL Database is created
echo
>
&2
"Complete! Virtuemart has been successfully copied to
$(
pwd
)
"
php /makedb.php
"
$JOOMLA_DB_HOST
"
"
$JOOMLA_DB_USER
"
"
$JOOMLA_DB_PASSWORD
"
"
$JOOMLA_DB_NAME
"
fi
echo
>
&2
"========================================================================"
echo
>
&2
"========================================================================"
echo
>
&2
echo
>
&2
echo
>
&2
"This server is now configured to run Joomla!"
echo
>
&2
"This server is now configured to run Joomla!"
echo
>
&2
"You will need the following database information to install Joomla:"
echo
>
&2
"You will need the following database information to install Joomla:"
echo
>
&2
"Host Name:
$JOOMLA_DB_HOST
"
echo
>
&2
"Host Name:
$JOOMLA_DB_HOST
"
echo
>
&2
"Database Name:
$JOOMLA_DB_NAME
"
echo
>
&2
"Database Name:
$JOOMLA_DB_NAME
"
echo
>
&2
"Database Username:
$JOOMLA_DB_USER
"
echo
>
&2
"Database Username:
$JOOMLA_DB_USER
"
echo
>
&2
"Database Password:
$JOOMLA_DB_PASSWORD
"
echo
>
&2
"Database Password:
$JOOMLA_DB_PASSWORD
"
echo
>
&2
echo
>
&2
echo
>
&2
"========================================================================"
echo
>
&2
"========================================================================"
# create the file to indicate this container has been configured:
touch
/etc/opentools-docker-configured
fi
fi
exec
"
$@
"
exec
"
$@
"
This diff is collapsed.
Click to expand it.
j2vm3_full/supervisord.conf
0 → 100644
+
10
−
0
View file @
8c5a1a35
[
supervisord
]
nodaemon
=
true
[
program
:
apache
]
command
=/
usr
/
local
/
bin
/
apache2
-
foreground
autorestart
=
true
[
include
]
files
= /
etc
/
supervisor
/
conf
.
d
/*.
conf
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment