-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
99 lines (78 loc) · 3.45 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Build application Panorama for Oracle
# Peter Ramm, 28.12.2016
# Usage:
# Build image: > docker build -t rammpeter/panorama .
# Create container from image: > docker run --name panorama -p8080:8080 -d rammpeter/panorama
# create container with tnsnames.ora from host and timezone set
# > docker run --name panorama -p8080:8080 -v $TNS_ADMIN/tnsnames.ora:/etc/tnsnames.ora -e TNS_ADMIN=/etc -e TZ="Europe/Berlin" -d rammpeter/panorama:latest
# STAGE 1: JRE build
FROM eclipse-temurin:21 as openjdk
#FROM openjdk:19 as openjdk
# Build small JRE image
RUN $JAVA_HOME/bin/jlink \
--verbose \
--add-modules ALL-MODULE-PATH \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /customjre
# STAGE 2: App build
FROM oraclelinux:8-slim as build_stage
ENV BACKEND_SRC_PATH=.
ARG JRUBY_VERSION
ENV JAVA_HOME=/opt/jre
ENV JRUBY_HOME=/opt/jruby-$JRUBY_VERSION
ENV PATH "${JAVA_HOME}/bin:$JRUBY_HOME/bin:$PATH"
ENV RAILS_ENV=production
WORKDIR /opt/panorama
COPY --from=openjdk /customjre $JAVA_HOME
COPY ${BACKEND_SRC_PATH} .
RUN microdnf update
RUN microdnf install wget tar gzip curl bash tzdata make clang
RUN echo "### install jruby" && \
(cd /opt && wget https://repo1.maven.org/maven2/org/jruby/jruby-dist/$JRUBY_VERSION/jruby-dist-$JRUBY_VERSION-bin.tar.gz) && \
(cd /opt && tar -xvf jruby-dist-$JRUBY_VERSION-bin.tar.gz && rm jruby-dist-$JRUBY_VERSION-bin.tar.gz) && \
ln -s /opt/jruby-$JRUBY_VERSION/bin/jruby /opt/jruby-$JRUBY_VERSION/bin/ruby && \
ruby -v
RUN date # show timezone
RUN echo '### due to error building digest-crc:6.0.3 sh: line 0: exec: jrake: not found' && \
ln -s /opt/jruby-$JRUBY_VERSION/bin/rake /opt/jruby-$JRUBY_VERSION/bin/jrake
RUN echo "### update installed system gems" && \
gem update --system --no-doc
RUN gem install --no-document bundler
RUN echo "gem: --no-rdoc --no-ri" > ~/.gemrc
RUN bundle config set deployment 'true'
RUN bundle config set --local without 'development test'
RUN rm -rf vendor/bundle # remove old vendor gems
RUN bundle install --jobs 4
RUN bundle exec rake assets:precompile
# RUN echo "### reduce storage / remove unnecessary packages" && gem cleanup && gem list && \
#RUN microdnf remove libmetalink expat wget tar gzip make gcc binutils glibc-devel libxcrypt-devel glibc-headers kernel-headers \
# libgomp pkgconf-pkg-config pkgconf libpkgconf pkgconf-m4 isl cpp libmpc
RUN microdnf clean all
RUN rm -rf $HOME/.bundle/cache && \
rm -f *.war && \
rm -f Panorama.log && \
rm -f Usage.log && \
rm -rf tmp/* && \
rm -rf log/* && \
rm -rf test/*
# FROM scratch
FROM oraclelinux:8-slim
MAINTAINER Peter Ramm <Peter@ramm-oberhermsdorf.de>
ARG JRUBY_VERSION
ENV JAVA_HOME=/opt/jre \
JRUBY_HOME=/opt/jruby-$JRUBY_VERSION \
WORKDIR=/opt/panorama
ENV PATH $JAVA_HOME/bin:$JRUBY_HOME/bin:$PATH
# RUN microdnf update && microdnf clean all
WORKDIR $WORKDIR
COPY --from=build_stage $JAVA_HOME $JAVA_HOME
COPY --from=build_stage $JRUBY_HOME $JRUBY_HOME
COPY --from=build_stage $WORKDIR $WORKDIR
# COPY --from=build_stage / /
EXPOSE 8080/tcp
# use bracket syntax to ensure it runs with PID 1 and receives SIGTERM signal
CMD ["/opt/panorama/run_Panorama_docker.sh"]
HEALTHCHECK --interval=5m --timeout=3s CMD curl localhost:8080 2>/dev/null | grep "Please choose saved connection " >/dev/null || exit 1