Skip to content

Commit

Permalink
added configuration scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
koert committed May 21, 2015
1 parent 1d13364 commit 9a8b708
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 31 deletions.
15 changes: 6 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
FROM dockerfile/java:oracle-java7
FROM ubuntu-oracle-jdk7
MAINTAINER Koert Zeilstra <koert.zeilstra@zencode.nl>

RUN apt-get update && \
apt-get install -y wget unzip pwgen expect openssh-server supervisor && \
apt-get install -y wget unzip pwgen expect && \
wget http://download.java.net/glassfish/4.1/release/glassfish-4.1.zip && \
unzip glassfish-4.1.zip -d /opt && \
rm glassfish-4.1.zip

ENV PATH /opt/glassfish4/bin:$PATH

ADD start-glassfish.sh /start-glassfish.sh
ADD initialize-glassfish.sh /initialize-glassfish.sh
ADD configure-glassfish.sh /configure-glassfish.sh
ADD change_admin_password.sh /change_admin_password.sh
ADD change_admin_password_func.sh /change_admin_password_func.sh
ADD enable_secure_admin.sh /enable_secure_admin.sh
RUN chmod +x /*.sh

ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
RUN mkdir -p /var/run/sshd /var/log/supervisor

RUN echo 'root:root' | chpasswd
RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed -i 's/PermitEmptyPasswords no/PermitEmptyPasswords yes/' /etc/ssh/sshd_config

RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# 22 (SSH), 4848 (administration), 8080 (HTTP listener), 8181 (HTTPS listener), 9009 (JPDA debug port)
# 4848 (administration), 8080 (HTTP listener), 8181 (HTTPS listener), 9009 (JPDA debug port)
EXPOSE 22 4848 8080 8181 9009

CMD ["/usr/bin/supervisord"]
CMD ["/start-glassfish.sh"]

16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
docker-glassfish
================

Base docker image to run a Glassfish 4.1 application server and includes SSHD.
Base docker image to run a Glassfish 4.1 application server.

Usage
-----

To create the image `glassfish-4.1`, execute the following command on the tutum-docker-glassfish folder:
To create the image `glassfish-4.1`, execute the following command on the docker-glassfish folder:

docker build -t koert/glassfish-4.1 .

To run the image and bind to port :

docker run -d -p 4022:22 -p 4848:4848 -p 8080:8080 -p 8181:8181 -p 9009:9009 koert/glassfish-4.1
docker run -d -p 4848:4848 -p 8080:8080 -p 8181:8181 -p 9009:9009 koert/glassfish-4.1

PS: 22 (for SSH, here mapped to 4022), 4848 (for administration), 8080 (for the HTTP listener), and 8181 (for the HTTPS listener), and 9009 (for tcp jpda debug)
PS: 4848 (for administration), 8080 (for the HTTP listener), and 8181 (for the HTTPS listener), and 9009 (for tcp jpda debug)

The first time that you run your container, a new user `admin` with all privileges
will be created in Glassfish with a random password. To get the password, check the logs
Expand Down Expand Up @@ -45,7 +45,7 @@ Setting a specific password for the admin account
If you want to use a preset password instead of a random generated one, you can
set the environment variable `GLASSFISH_PASS` to your specific password when running the container:

docker run -d -p 4022:22 -p 4848:4848 -p 8080:8080 -e GLASSFISH_PASS="mypass" koert/glassfish-4.1
docker run -d -p 4848:4848 -p 8080:8080 -e GLASSFISH_PASS="mypass" koert/glassfish-4.1

You can now test your deployment:

Expand All @@ -65,6 +65,12 @@ Notes
-----
Modified to use Oracle Java 7.

Auto deploy directory:
/opt/glassfish3/glassfish/domains/domain1/autodeploy

docker run -d -v ~/tmp/domains:/opt/glassfish4/glassfish/domains:ro -p 4848:4848 -p 8080:8080 -e GLASSFISH_PASS="mypass" koert/glassfish-4.1

docker run --rm -it -v ~/tmp/glassfish/import:/import:ro -v ~/tmp/glassfish/domains:/opt/glassfish4/glassfish/domains -p 4848:4848 -p 8080:8080 -e GLASSFISH_PASS="mypass" koert/glassfish-4.1 /bin/bash



13 changes: 0 additions & 13 deletions circle.yml

This file was deleted.

3 changes: 3 additions & 0 deletions configure-glassfish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash


10 changes: 10 additions & 0 deletions initialize-glassfish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

domains_dir=/opt/glassfish4/glassfish/domains

if [ ! "$(ls -A ${domains_dir})" ]; then
echo "${domains_dir} is empty, create test domain"
asadmin create-domain --nopassword test
fi


23 changes: 19 additions & 4 deletions start-glassfish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,28 @@

set -e

asadmin start-domain
if [ ! -f /.glassfish-initialized ]; then
/initialize-glassfish.sh
touch /.glassfish-initialized
fi

if [ ! -f /.glassfish_admin_password_changed ]; then
echo "=> Changing password"
echo "=> Start Glassfish server"
asadmin start-domain
echo "Set admin password"
/change_admin_password.sh

if [ ! -f /.glassfish_configured ]; then
/configure-glassfish.sh
touch /.glassfish-configured
fi

echo "=> Stop Glassfish server"
asadmin stop-domain
fi
echo "=> Restarting Glassfish server"
asadmin stop-domain

echo "=> Starting and running Glassfish server"
DEBUG_MODE=${DEBUG:-false}
echo "=> Debug mode is set to: ${DEBUG_MODE}"
asadmin start-domain --debug=${DEBUG_MODE} -w
exec asadmin start-domain --debug=${DEBUG_MODE} --watchdog

0 comments on commit 9a8b708

Please sign in to comment.