aboutsummaryrefslogtreecommitdiffstats
path: root/aai-traversal/src/main/resources/docker/Dockerfile
blob: 66cf41279ba5ab194dd4bae258ab8cfeea5ac010 (plain)
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
FROM ubuntu:14.04

ENV DEBIAN_FRONTEND noninteractive

ENV HTTP_PROXY  ${HTTP_PROXY}
ENV HTTPS_PROXY ${HTTP_PROXY}
ENV https_proxy ${HTTP_PROXY}
ENV http_proxy  ${HTTP_PROXY}

# Setup JAVA_HOME, this is useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64

# Install all the application requirements such as curl ksh and git
# Also install the chef and then remove it in one RUN command
# Because the docker files work like git commits and each command is committed
# So removing the chef in a different command will still have its in its build image
# Its good to be optimizing and removing any files that are not needed for docker images
# for the best possible performance out of your image

RUN if [ ! -z ${HTTP_PROXY} ]; then echo "Acquire::http::proxy  \"${HTTP_PROXY}\";" >> /etc/apt/apt.conf; fi && \
    if [ ! -z ${HTTP_PROXY} ]; then echo "Acquire::https::proxy \"${HTTP_PROXY}\";" >> /etc/apt/apt.conf; fi && \
    apt-get update && \
    apt-get install -y software-properties-common && \
    apt-get install --reinstall ca-certificates && \
    sudo -E add-apt-repository ppa:openjdk-r/ppa && \
    apt-get update && \
    apt-get -qq install -y openjdk-8-jre-headless git curl ksh && \
    curl -k -LO  https://packages.chef.io/stable/ubuntu/14.04/chefdk_0.17.17-1_amd64.deb || \
    curl --tlsv1 -LO https://packages.chef.io/stable/ubuntu/14.04/chefdk_0.17.17-1_amd64.deb && \
    dpkg -i chefdk_0.17.17-1_amd64.deb && \
    rm chefdk_0.17.17-1_amd64.deb && \
    rm -rf /var/lib/apt/lists/*

# Add the proper files into the docker image from your build
ADD ./opt/app /opt/app
ADD ./commonLibs/ /opt/app/commonLibs/
ADD init-chef.sh /init-chef.sh
ADD docker-entrypoint.sh /docker-entrypoint.sh
ADD aai.sh /etc/profile.d/aai.sh

# Expose the ports for outside linux to use
# 8446 is the important one to be used

EXPOSE 8446

# Create the /var/chef if it doesn't exist
WORKDIR /var/chef

# Create the directory structure of aai application resembling the development server
# hard-coding path to match ajsc version

RUN chmod 755 /init-chef.sh /docker-entrypoint.sh && chmod 644 /etc/profile.d/aai.sh && \
    mkdir /opt/aaihome && \
    useradd -r -ms /bin/bash -d /opt/aaihome/aaiadmin aaiadmin && \
    mkdir -p /opt/app/${project.artifactId}  && \
    chown aaiadmin:aaiadmin /opt/app/${project.artifactId} && \
    chown -R aaiadmin:aaiadmin /opt/app/${project.artifactId} && \
    mkdir -p /opt/aai/logroot && \
    chown -R aaiadmin:aaiadmin /opt/aai/logroot && \
    ln -s /opt/app/${project.artifactId}/bin scripts && \
    mkdir -p /opt/app/${project.artifactId}/extApps && chown -R aaiadmin:aaiadmin /opt/app/${project.artifactId}/extApps && \
    find /opt/app/${project.artifactId}/bin -name "*.sh" -exec chmod 755 {} + && \
    chown aaiadmin:aaiadmin /docker-entrypoint.sh && \
    chown -R aaiadmin:aaiadmin /var/chef && \
    mkdir -p /opt/aai/logroot/AAI-GQ && \
    chown aaiadmin:aaiadmin /opt/aai/logroot/AAI-GQ && \
    ln -s /opt/aai/logroot/AAI-GQ /opt/app/${project.artifactId}/logs && \
    chown -R aaiadmin:aaiadmin /opt/app/${project.artifactId}/logs

VOLUME /opt/aai/logroot/AAI-GQ

WORKDIR /

USER aaiadmin

# When the container is started this is the entrypoint script
# that docker will run. Make sure this script doesn't end abruptly
# If you want the container running even if the main application stops
# You can run a ever lasting process like tail -f /dev/null
# Or something like that at the end of the docker-entrypoint script
# So if the main application you are planning on running fails
# the docker container keeps on running forever

ENTRYPOINT ./docker-entrypoint.sh