Skip to content

Commit

Permalink
Merge branch '138-docker-image-build-product'
Browse files Browse the repository at this point in the history
  • Loading branch information
andponlin committed Aug 30, 2018
2 parents 07a6ece + 2368884 commit 4a31419
Show file tree
Hide file tree
Showing 10 changed files with 396 additions and 63 deletions.
7 changes: 6 additions & 1 deletion haikudepotserver-docs/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
~ Copyright 2018, Andrew Lindesay
~ Distributed under the terms of the MIT License.
-->

<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>
<parent>
<artifactId>haikudepotserver-parent</artifactId>
<groupId>org.haiku</groupId>
<relativePath>../haikudepotserver-parent</relativePath>
Expand Down
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
~ Copyright 2018, Andrew Lindesay
~ Distributed under the terms of the MIT License.
-->

<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">

<modelVersion>4.0.0</modelVersion>
Expand All @@ -20,7 +25,6 @@

<profiles>
<profile>

<id>rpm-capable-build</id>

<activation>
Expand All @@ -38,6 +42,7 @@
</modules>

</profile>

</profiles>

</project>
61 changes: 61 additions & 0 deletions support/deployment/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# =====================================
# Copyright 2018, Andrew Lindesay
# Distributed under the terms of the MIT License.
# =====================================

# This Dockerfile is used to build an image that is able to run an HDS server.
# Do not use this file from the master or other working branch, but instead
# use one from a release tag because this version of the file will have the
# correct versions inserted into it. See the documentation for further
# details on how this deployment mechanism works.

FROM ubuntu:16.04

# These environment variables will be set using the release script. It will
# copy the correct values from the poms into these variables so that the right
# versions of the artefacts are used in the Docker container.

ENV HDS_VERSION "???"
ENV JETTY_VERSION "???"
ENV PG_VERSION "???"

ENV JAVA_BIN "java"

ENV INSTALL_ROOT "/opt/haikudepotserver"
ENV INSTALL_HVIF2PNG_PATH "${INSTALL_ROOT}/hvif2png-hrev51165/bin/hvif2png.sh"

ENV HDS_WAR "haikudepotserver-webapp-${HDS_VERSION}.war"
ENV HDS_WAR_DOWNLOAD_URL "https://github.com/aplgithub/haikudepotserver/releases/download/haikudepotserver-${HDS_VERSION}/${HDS_WAR}"
ENV HDS_PORT 8080

ENV JETTY_JAR "jetty-runner-${JETTY_VERSION}.jar"
ENV JETTY_DOWNLOAD_URL "http://central.maven.org/maven2/org/eclipse/jetty/jetty-runner/${JETTY_VERSION}/${JETTY_JAR}"

ENV PG_JAR "postgresql-${PG_VERSION}.jar"
ENV PG_DOWNLOAD_URL "http://central.maven.org/maven2/org/postgresql/postgresql/${PG_VERSION}/${PG_JAR}"

ENV HVIF2PNG_VERSION "hvif2png-hrev51165-linux-x86_64"

RUN mkdir -p "${INSTALL_ROOT}"
RUN apt-get update && apt-get -y install optipng libpng12-0 curl openjdk-8-jdk fontconfig ttf-dejavu

COPY config.properties ${INSTALL_ROOT}
COPY logback.xml ${INSTALL_ROOT}
COPY launch.sh ${INSTALL_ROOT}

ADD ${JETTY_DOWNLOAD_URL} ${INSTALL_ROOT}/${JETTY_JAR}
ADD ${HVIF2PNG_VERSION}.tgz ${INSTALL_ROOT}
ADD ${PG_DOWNLOAD_URL} ${INSTALL_ROOT}/${PG_JAR}
ADD ${HDS_WAR_DOWNLOAD_URL} ${INSTALL_ROOT}/${HDS_WAR}

RUN echo "HDS_ROOT=${INSTALL_ROOT}" > ${INSTALL_ROOT}/launchenv.sh
RUN echo "JAVA_BIN=${JAVA_BIN}" >> ${INSTALL_ROOT}/launchenv.sh
RUN echo "HDS_HVIF2PNG_PATH=${INSTALL_HVIF2PNG_PATH}" >> ${INSTALL_ROOT}/launchenv.sh
RUN echo "HDS_PORT=${HDS_PORT}" >> ${INSTALL_ROOT}/launchenv.sh
RUN echo "HDS_WAR=${HDS_WAR}" >> ${INSTALL_ROOT}/launchenv.sh
RUN echo "JETTY_JAR=${JETTY_JAR}" >> ${INSTALL_ROOT}/launchenv.sh
RUN echo "PG_JAR=${PG_JAR}" >> ${INSTALL_ROOT}/launchenv.sh

CMD [ "sh", "/opt/haikudepotserver/launch.sh" ]

EXPOSE ${HDS_PORT}
128 changes: 128 additions & 0 deletions support/deployment/config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#
# Copyright 2018, Andrew Lindesay
# Distributed under the terms of the MIT License.
#

# ===========================================
# haikudepotserver docker - configuration file
# ===========================================

# -------------------------------------------
# general

captcha.expiryseconds=240

pkgversion.viewcounter.protectrecurringincrementfromsameclient=true

deployment.isproduction=true

architecture.default.code=x86_gcc2

optipng.path=/usr/bin/optipng

# When set (either "true" or "false"), the repository import process will
# obtain the data for the package and will thereby figure out the size of
# the package.
repository.import.populatepayloadlength=true

# Configures a minimum version for the HaikiDepot desktop application.
# Versions of HD desktop application less than this minimum are
# disallowed.

desktop.application.version.min=0.0.1

# If configured, this path should point to the "hvif2png.sh" script. See
# the documentation on information as to where this can be sourced from.

# docker env-vars
#hvif2png.path=


# -------------------------------------------
# database connection

# docker env-vars
jdbc.driver=org.postgresql.Driver
#jdbc.url=
#jdbc.username=
#jdbc.password=

flyway.migrate=true

# This should be true in production.
flyway.validateOnMigrate=false

# When configured, this value will indicate the size of the cache dedicated to storing
# query results. It will default to a sensible value.

#cayenne.query.cache.size=250

# -------------------------------------------
# user ratings

# How many versions to go back from the latest version in order
# to find user ratings to aggregate.

userrating.aggregation.pkg.versionsback=2

# How many ratings must be present before an aggregate can be
# derived; too few and the result will be from too small a sample
# to be meaningful.

userrating.aggregation.pkg.minratings=1

# -------------------------------------------
# web infrastructure

# This value relates to the built-in JAWR web-resource compression and
# concatination system. Review the JAWR documentation for details on
# the effects of configuring this value to true.

#jawr.debug.on=false

# This URL provides a base URL that the application can then add to when
# it formulates URLs that are to be used outside of the application; for
# example, URLs in ATOM feeds etc...

baseurl=https://depot.haiku-os.org

# -------------------------------------------
# web security

# This is the number of seconds for which an authentication token is
# valid for.

#authentication.jws.expiryseconds=

# This secret is used to sign the tokens used to communicate between
# the client and the server. This value should be very hard to guess.
# The output of the command "uuidgen" would be appropriate. This
# value must be kept secret and not disclosed in public.
# commented out to force the value to be considered

#authentication.jws.sharedkey=

# This value is used in the production and consumption of the tokens
# between the client and the server. It is intended that this is
# consistent for a given deployment. Sample values that may be
# appropriate;
#
# dev.hds
# prod.hds
# test.hds
#

authentication.jws.issuer=prod.hds

# -------------------------------------------
# email-related

#smtp.host=smtp
#smtp.port=25
#smtp.username=
#smtp.password=
#smtp.auth=false
#smtp.starttls=false
email.from=[email protected]

# -------------------------------------------
9 changes: 9 additions & 0 deletions support/deployment/hds_secrets
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This is an example secrets file that might be used to convey
# system secrets to the HDS application through a shared directory
# to the docker container.

HDS_JDBC_URL=jdbc:postgresql://somepghost:5432/haikudepotserver
HDS_JDBC_USERNAME=somepguser
HDS_JDBC_PASSWORD=somepgpassword
HDS_SMTP_HOST=somesmtpserver
HDS_AUTHENTICATION_JWS_ISSUER=justtesting.hds
Binary file not shown.
25 changes: 25 additions & 0 deletions support/deployment/launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# launch file for the haikudepotserver system.

. "$(dirname $0)/launchenv.sh"
. "/secrets/hds_secrets"

"${JAVA_BIN}" \
"-Dfile.encoding=UTF-8" \
"-Dlogback.configurationFile=${DS_ROOT}/logback.xml" \
"-Duser.timezone=GMT0" \
"-Xms256m" \
"-Xmx320m" \
"-Djava.net.preferIPv4Stack=true" \
"-Djava.awt.headless=true" \
"-Dconfig.properties=file://${HDS_ROOT}/config.properties" \
"-Dhvif2png.path=${HDS_HVIF2PNG_PATH}" \
"-Djdbc.url=${HDS_JDBC_URL}" \
"-Djdbc.username=${HDS_JDBC_USERNAME}" \
"-Djdbc.password=${HDS_JDBC_PASSWORD}" \
"-Dsmtp.host=${HDS_SMTP_HOST}" \
"-Dauthentication.jws.issuer=${HDS_AUTHENTICATION_JWS_ISSUER}" \
"-jar" "${HDS_ROOT}/${JETTY_JAR}" \
"--jar" "${HDS_ROOT}/${PG_JAR}" \
"--port" "${HDS_PORT}" \
"${HDS_ROOT}/${HDS_WAR}" \

23 changes: 23 additions & 0 deletions support/deployment/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
~ Copyright 2018, Andrew Lindesay
~ Distributed under the terms of the MIT License.
-->

<configuration>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{ISO8601} %X{authUserNickname}/%X{userAgentCode} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<logger name="org.apache.cayenne" level="warn"/>
<logger name="com.googlecode.flyway" level="debug"/>

<root level="info">
<appender-ref ref="STDOUT" />
</root>

</configuration>
Loading

0 comments on commit 4a31419

Please sign in to comment.