forked from sonatype/docker-nexus3
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile-alpine.template
72 lines (58 loc) · 2.41 KB
/
Dockerfile-alpine.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
FROM alpine:3.4
MAINTAINER Jeffry Hesse <jeffryxtron+docker@gmail.com>
ENV JAVA_HOME=/opt/java \
SONATYPE_DIR=/opt/sonatype \
NEXUS_DATA=/nexus-data \
NEXUS_CONTEXT=''
ENV NEXUS_HOME=${SONATYPE_DIR}/nexus \
SONATYPE_WORK=${SONATYPE_DIR}/sonatype-work
ARG JAVA_VERSION_MAJOR=%%VERSION_MAJOR%%
ARG JAVA_VERSION_MINOR=%%VERSION_MINOR%%
ARG JAVA_VERSION_BUILD=%%VERSION_BUILD%%
ARG GLIBC_VERSION=%%GLIBC_VERSION%%
ARG JAVA_URL=http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-b${JAVA_VERSION_BUILD}/server-jre-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.tar.gz
ARG GLIBC_URL=https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}
ARG NEXUS_VERSION=%%NEXUS_VERSION%%
ARG NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/nexus-${NEXUS_VERSION}-unix.tar.gz
ARG BUILD_DEPENDENCIES="curl tar"
RUN apk upgrade --update && \
apk add --update ${BUILD_DEPENDENCIES} && \
for pkg in glibc glibc-bin glibc-i18n; do \
curl -sSL ${GLIBC_URL}/${pkg}-${GLIBC_VERSION}.apk -o /tmp/${pkg}.apk; \
done && \
apk add --allow-untrusted /tmp/*.apk && \
rm -v /tmp/*.apk && \
/usr/glibc-compat/bin/localedef -i en_US -f UTF-8 en_US.UTF-8 && \
/usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib
# install Oracle JRE
RUN mkdir -p /opt && \
curl --fail --silent --location --retry 3 \
--header "Cookie: oraclelicense=accept-securebackup-cookie; " ${JAVA_URL} \
| tar -xz -C /opt && \
ln -s /opt/jdk1.${JAVA_VERSION_MAJOR}.0_${JAVA_VERSION_MINOR} ${JAVA_HOME}
# install nexus
RUN mkdir -p ${NEXUS_HOME} && \
curl --fail --silent --location --retry 3 \
${NEXUS_DOWNLOAD_URL} \
| gunzip \
| tar x -C ${NEXUS_HOME} --strip-components=1 nexus-${NEXUS_VERSION} && \
chown -R root:root ${NEXUS_HOME}
# configure nexus
RUN sed \
-e '/^nexus-context/ s:$:${NEXUS_CONTEXT}:' \
-i ${NEXUS_HOME}/etc/nexus-default.properties \
&& sed \
-e '/^-Xms/d' \
-e '/^-Xmx/d' \
-i ${NEXUS_HOME}/bin/nexus.vmoptions
RUN addgroup -S -g 201 nexus && \
adduser -S -u 200 -G nexus -h ${NEXUS_DATA} -s /bin/false nexus && \
mkdir -p ${NEXUS_DATA}/etc ${NEXUS_DATA}/log ${NEXUS_DATA}/tmp ${SONATYPE_WORK} && \
ln -s ${NEXUS_DATA} ${SONATYPE_WORK}/nexus3 && \
chown -R nexus:nexus ${NEXUS_DATA}
VOLUME ${NEXUS_DATA}
EXPOSE 8081
USER nexus
WORKDIR ${NEXUS_HOME}
ENV INSTALL4J_ADD_VM_PARAMS="-Xms1200m -Xmx1200m"
CMD ["bin/nexus", "run"]