forked from travelaudience/docker-nexus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
81 lines (63 loc) · 2.62 KB
/
Dockerfile
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
73
74
75
76
77
78
79
80
81
FROM alpine:3.18
LABEL MAINTAINER [email protected]
# java
ENV JAVA_HOME=/usr/lib/jvm/default-jvm/jre
# nexus latest binary release link
# https://help.sonatype.com/repomanager3/download/download-archives---repository-manager-3
# nexus gpg key link
# https://help.sonatype.com/repomanager3/product-information/download#Download-RelatedLinks
# nexus
ENV NEXUS_VERSION "3.75.1-01"
ENV NEXUS_DOWNLOAD_URL "https://download.sonatype.com/nexus/3"
ENV NEXUS_TARBALL_URL "${NEXUS_DOWNLOAD_URL}/nexus-${NEXUS_VERSION}-unix.tar.gz"
ENV NEXUS_TARBALL_ASC_URL "${NEXUS_DOWNLOAD_URL}/nexus-${NEXUS_VERSION}-unix.tar.gz.asc"
ENV GPG_KEY "C26BAB2B209A8FF4"
ENV SONATYPE_DIR /opt/sonatype
ENV NEXUS_HOME "${SONATYPE_DIR}/nexus"
ENV NEXUS_DATA /nexus-data
ENV NEXUS_CONTEXT ''
ENV SONATYPE_WORK ${SONATYPE_DIR}/sonatype-work
ENV NEXUS_DATA_CHOWN "true"
# java version link
# https://help.sonatype.com/repomanager3/product-information/sonatype-nexus-repository-system-requirements#SonatypeNexusRepositorySystemRequirements-Java
# Install prerequisites
RUN apk add --no-cache --update bash ca-certificates runit su-exec util-linux openjdk8-jre
# Install nexus
RUN apk add --no-cache -t .build-deps wget gnupg openssl \
&& cd /tmp \
&& echo "===> Installing Nexus ${NEXUS_VERSION}..." \
&& wget -O nexus.tar.gz $NEXUS_TARBALL_URL \
&& wget -O nexus.tar.gz.asc $NEXUS_TARBALL_ASC_URL \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --recv-keys $GPG_KEY \
&& gpg --batch --verify nexus.tar.gz.asc nexus.tar.gz \
&& (rm -r $GNUPGHOME nexus.tar.gz.asc || true) \
&& tar -xf nexus.tar.gz \
&& mkdir -p $SONATYPE_DIR \
&& mv nexus-$NEXUS_VERSION $NEXUS_HOME \
&& cd $NEXUS_HOME \
&& ls -las \
&& adduser -h $NEXUS_DATA -DH -s /sbin/nologin nexus \
&& chown -R nexus:nexus $NEXUS_HOME \
&& rm -rf /tmp/* /var/cache/apk/* \
&& apk del --purge .build-deps
# 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 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}
# Update logback configuration to store 30 days logs rather than 90 days default
RUN sed -i -e 's|<maxHistory>90</maxHistory>|<maxHistory>30</maxHistory>|g' ${NEXUS_HOME}/etc/logback/logback*.xml
# Copy runnable script
COPY run /etc/service/nexus/run
VOLUME ${NEXUS_DATA}
EXPOSE 8081
WORKDIR ${NEXUS_HOME}
ENV INSTALL4J_ADD_VM_PARAMS="-Xms1200m -Xmx1200m"
CMD ["/sbin/runsvdir", "-P", "/etc/service"]