Skip to content

Instantly share code, notes, and snippets.

@jeanatcismet
Last active April 6, 2016 10:44
Show Gist options
  • Save jeanatcismet/c383939cab551597123e1006e805131b to your computer and use it in GitHub Desktop.
Save jeanatcismet/c383939cab551597123e1006e805131b to your computer and use it in GitHub Desktop.
CidsRef Dockerfiles
#!/bin/bash
docker build -t cismet/postgresql-postgis -f Dockerfile_postgresql-postgis .
docker build -t cismet/maven -f Dockerfile_maven .
docker build -t cismet/cidsref -f Dockerfile_cidsref .
db:
image: cismet/postgresql-postgis
ports:
- "5434:5432"
volumes:
- ~/container-data/cids_reference.sql:/data/dumps/cids_reference.sql
cidsref:
image: cismet/cidsref
links:
- "db:db"
ports:
- "9986:9986"
volumes:
- ~/container-data/settings.xml:/data/import/settings.xml
- ~/container-data/pom.xml:/data/import/pom.xml
- ~/container-data/runtime.properties:/data/import/runtime.properties
FROM cismet/maven
MAINTAINER Jean-Michel Ruiz <jean.ruiz@cismet.de>
ENV DATA_DIR /data
ENV LIB_DIR /data/lib
ENV SERVER_DIR /data/server
ENV IMPORT_DIR /data/import
ENV PGPASSWORD postgres
RUN mkdir -p ${DATA_DIR}/
RUN mkdir -p ${LIB_DIR}/
RUN mkdir -p ${SERVER_DIR}/
RUN mkdir -p ${IMPORT_DIR}/
WORKDIR ${DATA_DIR}/
RUN apt-get update \
&& apt-get install -y postgresql-client \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p ${LIB_DIR}/m2/javax/servlet/jsp/jsp-api/2.1.2
COPY jsp-api-2.1.2.pom ${LIB_DIR}/m2/javax/servlet/jsp/jsp-api/2.1.2/
VOLUME ${DATA_DIR}
EXPOSE 9986
CMD \
echo '###### BUILD DISTRIBUTION ######' && \
cp ${IMPORT_DIR}/settings.xml ${DATA_DIR}/ && \
cp ${IMPORT_DIR}/pom.xml ${SERVER_DIR}/ && \
cd ${SERVER_DIR} && \
mvn -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -s ${DATA_DIR}/settings.xml -Dcids.generate-lib.checkSignature=false -Dcids.generate-lib.sign=false $* clean package -U && \
echo '###### START SERVER ######' && \
cp ${IMPORT_DIR}/runtime.properties ${SERVER_DIR}/ && \
sed -i -- "s/__DB_HOST__/${DB_PORT_5432_TCP_ADDR}/g" ${SERVER_DIR}/runtime.properties && \
sed -i -- "s/__DB_PORT__/${DB_PORT_5432_TCP_PORT}/g" ${SERVER_DIR}/runtime.properties && \
/usr/bin/java -Xms64m -Xmx800m -Djava.security.policy=policy.file -jar ${LIB_DIR}/starterCidsRef/cids-server-2.0-SNAPSHOT-starter.jar ${SERVER_DIR}/runtime.properties
FROM ubuntu
MAINTAINER Jean-Michel Ruiz <jean.ruiz@cismet.de>
ENV JAVA_VERSION 8
ENV JAVA_UPDATE 77
ENV JAVA_BUILD 03
ENV OPENSSL_VERSION 1.0.2g
ENV MAVEN_VERSION 3.3.9
ENV JAVA_HOME /usr/lib/jvm/java-${JAVA_VERSION}-oracle
ENV JRE_HOME ${JAVA_HOME}/jre
ENV MAVEN_HOME /usr/share/maven
RUN apt-get update \
&& apt-get -y --no-install-recommends install ca-certificates curl gcc libc6-dev libssl-dev make
RUN mkdir -p /usr/lib/jvm
RUN curl --silent --location --retry 3 --cacert /etc/ssl/certs/GeoTrust_Global_CA.pem --header "Cookie: oraclelicense=accept-securebackup-cookie;" http://download.oracle.com/otn-pub/java/jdk/"${JAVA_VERSION}"u"${JAVA_UPDATE}"-b"${JAVA_BUILD}"/server-jre-"${JAVA_VERSION}"u"${JAVA_UPDATE}"-linux-x64.tar.gz | tar xz -C /tmp
RUN mv /tmp/jdk1.${JAVA_VERSION}.0_${JAVA_UPDATE} "${JAVA_HOME}"
RUN curl --silent --location --retry 3 --cacert /etc/ssl/certs/GlobalSign_Root_CA.pem https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz | tar xz -C /tmp
RUN cd /tmp/openssl-"${OPENSSL_VERSION}" ; ./config --prefix=/usr
RUN cd /tmp/openssl-"${OPENSSL_VERSION}" ; make clean
RUN cd /tmp/openssl-"${OPENSSL_VERSION}" ; make
RUN cd /tmp/openssl-"${OPENSSL_VERSION}" ; make install
RUN mkdir -p ${MAVEN_HOME}
RUN curl -fsSL http://apache.osuosl.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz | tar -xzC ${MAVEN_HOME} --strip-components=1
RUN ln -s ${MAVEN_HOME}/bin/mvn /usr/bin/mvn
RUN apt-get remove --purge --auto-remove -y gcc libc6-dev libssl-dev make
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN update-alternatives --install "/usr/bin/java" "java" "${JRE_HOME}/bin/java" 1
RUN update-alternatives --install "/usr/bin/javac" "javac" "${JAVA_HOME}/bin/javac" 1
RUN update-alternatives --set java "${JRE_HOME}/bin/java"
RUN update-alternatives --set javac "${JAVA_HOME}/bin/javac"
FROM ubuntu
MAINTAINER Jean-Michel Ruiz "jean.ruiz@cismet.de"
# ENV
ENV POSTGRES_PASSWORD postgres
ENV DATA_DIR /data
ENV DUMPS_DIR /data/dumps
ENV PG_VERSION 9.0.3
ENV GEOS_VERSION 3.3.5
ENV PROJ4_VERSION 4.8.0
ENV POSTGIS_VERSION 1.5.5
ENV LOCALE de_DE
ENV ENCODING UTF-8
WORKDIR /usr/local/
# install dependencies
RUN apt-get update \
&& apt-get install -y build-essential gcc-4.7 libgdal1h libreadline6-dev libxml2 libxml2-dev locales zlib1g-dev
# locale
RUN localedef -i $LOCALE -c -f $ENCODING -A /usr/share/locale/locale.alias ${LOCALE}.${ENCODING}
RUN locale-gen ${LOCALE}.${ENCODING}
ADD https://ftp.postgresql.org/pub/source/v${PG_VERSION}/postgresql-${PG_VERSION}.tar.bz2 src/
RUN cd src/ ; tar -xjvf postgresql-${PG_VERSION}.tar.bz2
RUN cd src/postgresql-${PG_VERSION} ; ./configure CC='gcc-4.7 -m64' --prefix=/usr/local --with-pgport=5432
RUN cd src/postgresql-${PG_VERSION} ; make
RUN cd src/postgresql-${PG_VERSION} ; make install
RUN cd src/postgresql-${PG_VERSION}/contrib ; make all
RUN cd src/postgresql-${PG_VERSION}/contrib ; make install
RUN ldconfig
# build & install geos
ADD http://download.osgeo.org/geos/geos-${GEOS_VERSION}.tar.bz2 src/
RUN cd src/ ; tar -xjvf geos-${GEOS_VERSION}.tar.bz2
RUN cd src/geos-${GEOS_VERSION} ; ./configure
RUN cd src/geos-${GEOS_VERSION} ; make
RUN cd src/geos-${GEOS_VERSION} ; make install
RUN ldconfig
# build & install proj4
ADD http://download.osgeo.org/proj/proj-${PROJ4_VERSION}.tar.gz src/
RUN cd src/ ; tar -xvf proj-${PROJ4_VERSION}.tar.gz
RUN cd src/proj-${PROJ4_VERSION} ; ./configure
RUN cd src/proj-${PROJ4_VERSION} ; make
RUN cd src/proj-${PROJ4_VERSION} ; make install
RUN ldconfig
# build & install postgis
ADD http://download.osgeo.org/postgis/source/postgis-${POSTGIS_VERSION}.tar.gz src/
RUN cd src/ ; tar -xvf postgis-${POSTGIS_VERSION}.tar.gz
RUN cd src/postgis-${POSTGIS_VERSION} ; ./configure
RUN cd src/postgis-${POSTGIS_VERSION} ; make
RUN cd src/postgis-${POSTGIS_VERSION} ; make install
RUN ldconfig
# create postgres user
RUN groupadd postgres
RUN useradd -r postgres -g postgres
RUN echo "postgres:${POSTGRES_PASSWORD}" | chpasswd -e
# create data directory
RUN mkdir -p ${DATA_DIR}
RUN chown postgres:postgres ${DATA_DIR}
RUN chmod 700 ${DATA_DIR}
USER postgres
# initdb
RUN initdb \
--encoding=${ENCODING} \
--locale=${LOCALE}.${ENCODING} \
--lc-collate=${LOCALE}.${ENCODING} \
--lc-monetary=${LOCALE}.${ENCODING} \
--lc-numeric=${LOCALE}.${ENCODING} \
--lc-time=${LOCALE}.${ENCODING} \
-D ${DATA_DIR}
# create dumps directory
RUN mkdir -p ${DUMPS_DIR}
USER root
# conf
RUN echo "host all all 0.0.0.0/0 md5" >> $DATA_DIR/pg_hba.conf
RUN echo "listen_addresses='*'" >> $DATA_DIR/postgresql.conf
USER postgres
RUN pg_ctl -w -D ${DATA_DIR} start \
# set password
&& psql -c "alter role postgres password '${POSTGRES_PASSWORD}'" \
&& createdb template_postgis \
# postgis template
&& psql template_postgis -f src/postgis-${POSTGIS_VERSION}/postgis/postgis.sql \
&& psql template_postgis -f src/postgis-${POSTGIS_VERSION}/spatial_ref_sys.sql \
&& pg_ctl -w -D ${DATA_DIR} stop
USER root
# clean up
RUN apt-get remove --purge --auto-remove -y build-essential gcc-4.7 libreadline6-dev libxml2-dev zlib1g-dev
RUN rm -rf /var/lib/apt/lists/* src/*
# port
EXPOSE 5432
# data
VOLUME ${DATA_DIR}
# start
CMD \
su postgres -c "pg_ctl -w -D ${DATA_DIR} start" && \
for DUMP_FULL_PATH in ${DUMPS_DIR}/*.sql; \
do DUMP_FILE=`basename ${DUMP_FULL_PATH}`; \
DUMP_DB_NAME=${DUMP_FILE%%.sql}; \
dropdb -U postgres ${DUMP_DB_NAME} 2> /dev/null; \
createdb -U postgres -T template_postgis ${DUMP_DB_NAME} && \
psql -U postgres ${DUMP_DB_NAME} < ${DUMP_FULL_PATH}; \
done && \
su postgres -c "pg_ctl -w -D ${DATA_DIR} stop" && \
su postgres -c "postgres -D ${DATA_DIR}"
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can obtain
* a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
* or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
* Sun designates this particular file as subject to the "Classpath" exception
* as provided by Sun in the GPL Version 2 section of the License file that
* accompanied this code. If applicable, add the following below the License
* Header, with the fields enclosed by brackets [] replaced by your own
* identifying information: "Portions Copyrighted [year]
* [name of copyright owner]"
*
* Contributor(s):
*
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.glassfish.web</groupId>
<artifactId>jsp</artifactId>
<version>2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<packaging>jar</packaging>
<version>${jsp-api.version}</version>
<name>JavaServer Pages(TM) API v${jsp-api.version}</name>
<developers>
<developer>
<id>kchung</id>
<name>Kin Man Chung</name>
<url>http://blogs.sun.com/kchung/</url>
<organization>Sun Microsystems, Inc.</organization>
<roles>
<role>lead</role>
</roles>
</developer>
</developers>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<phase>javadoc</phase>
<goals>
<goal>javadoc</goal>
</goals>
<configuration>
<groups>
<group>
<title>JavaServer Pages API Documentation</title>
<packages>javax.servlet.jsp</packages>
</group>
</groups>
<bottom>Portions Copyright &amp;copy; 1999-2002 The Apache Software Foundation. All Rights Reserved. Portions Copyright &amp;copy; 2005-2006 Sun Microsystems Inc. All Rights Reserve</bottom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment