-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
70 lines (52 loc) · 1.73 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
# Base image to be used
FROM ubuntu:20.04
# Environment Variables
ENV TERM linux
ENV DEBIAN_FRONTEND noninteractive
# Input data
ENV OPSGENIE_LAMP_VERSION=3.1.4
ARG NON_ROOT_USER=nroot
# Change to ROOT user to do maintenance/install tasks
USER root
# Working directory
WORKDIR /tmp
# Install packages
RUN apt-get update && apt-get install -y \
python3.8 \
python3-pip \
git \
wget \
jq \
curl \
unzip \
gnupg \
bash
# Check versions
RUN python3 -V
# Cleanup
RUN apt-get update && apt-get upgrade -y && apt-get autoremove -y
# Copy requirements.txt file to workdir
COPY requirements.txt /tmp/
# Install pip components from requirements.txt
RUN pip3 install -r requirements.txt
# Install OPSGENIE LAMP
RUN curl -L https://github.com/opsgenie/opsgenie-lamp/releases/download/v${OPSGENIE_LAMP_VERSION}/opsgenie-lamp_${OPSGENIE_LAMP_VERSION}_linux_amd64.zip > /tmp/opsgenie-lamp.zip \
&& cd /tmp && ls && unzip opsgenie-lamp.zip && mv opsgenie-lamp_v${OPSGENIE_LAMP_VERSION} /usr/local/bin/opsgenie-lamp && chmod +x /usr/local/bin/opsgenie-lamp && rm -rf /tmp/opsgenie-lamp*
# Check versions
RUN opsgenie-lamp --version
# Clean up tmp directory
RUN rm --recursive --force -- *
# Create a non-root user
RUN useradd --create-home --shell /bin/bash ${NON_ROOT_USER} && su - ${NON_ROOT_USER}
# Use non-root user
USER ${NON_ROOT_USER}
# Set workdir to user home
WORKDIR /home/${NON_ROOT_USER}
# Configure SSH client
RUN mkdir -p /home/${NON_ROOT_USER}/.ssh && \
chmod 700 /home/${NON_ROOT_USER}/.ssh && \
printf "Host *\\n\\tStrictHostKeyChecking no\\n\\n" > /home/${NON_ROOT_USER}/.ssh/config
# Copy opsgenie_cleaner.py script to HOME.
COPY opsgenie_cleaner.py /home/${NON_ROOT_USER}
# Command to execute
CMD ["bash"]