forked from runwhen-contrib/codecollection-devtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
67 lines (55 loc) · 2.44 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
FROM python:3.9.1 as runtime
ENV WORKDIR /app
ENV ROBOT_LOG_DIR /robot_logs
RUN mkdir -p $WORKDIR
WORKDIR $WORKDIR
USER root
# Install and validate kubectl
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
RUN curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
RUN echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
RUN rm kubectl.sha256
RUN chmod +x kubectl
RUN mv kubectl /usr/local/bin/
# Install packages
RUN apt-get update && \
apt install -y jq && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/apt
# Setup user to represent developer permissions in container
ARG USERNAME=python
ARG USER_UID=1000
ARG USER_GID=1000
RUN useradd -rm -d /home/$USERNAME -s /bin/bash -g root -G sudo -u $USER_UID $USERNAME
COPY . .
# Robotframework setup
ENV PYTHONPATH "$PYTHONPATH:.:$WORKDIR/rw-public-codecollection/libraries:$WORKDIR/rw-public-codecollection/codebundles:$WORKDIR/codecollection/libraries:$WORKDIR/codecollection/codebundles:$WORKDIR/dev_facade"
# viewable logs
RUN mkdir -p $ROBOT_LOG_DIR
RUN chown -R 1000:0 $ROBOT_LOG_DIR
RUN chown 1000:0 $WORKDIR/ro
ENV PATH "$PATH:/home/python/.local/bin/:$WORKDIR/"
# runwhen dev env
ENV RW_SVC_URLS '{"kubectl":"https://kubectl.sandbox.runwhen.com","curl":"https://curl.sandbox.runwhen.com","grpcurl":"https://grpcurl.sandbox.runwhen.com","gcloud":"https://gcloud.sandbox.runwhen.com","aws":"https://aws.sandbox.runwhen.com"}'
RUN chown 1000:0 -R $WORKDIR
# Install lnav (https://github.com/tstack/lnav)
ENV LNAV_VERSION 0.11.2
RUN wget https://github.com/tstack/lnav/releases/download/v${LNAV_VERSION}/lnav-${LNAV_VERSION}-x86_64-linux-musl.zip && \
unzip lnav-${LNAV_VERSION}-x86_64-linux-musl.zip && \
cd lnav-${LNAV_VERSION} && \
mkdir -p /home/python/.lnav/formats/installed && \
chown -R 1000:0 /home/python/.lnav && \
mv lnav /usr/local/bin/ && \
chmod 777 /usr/local/bin/lnav
RUN mv .pylintrc.google ~/.pylintrc
USER $USERNAME
RUN pip install --user pylint
RUN pip install --user black
# Install gcloud sdk
# TODO: fix userspace install and move up in build so it doesnt break cache
RUN curl -sSL https://sdk.cloud.google.com | bash
ENV PATH "$PATH:/home/python/google-cloud-sdk/bin/"
RUN gcloud components install gke-gcloud-auth-plugin --quiet
EXPOSE 3000
CMD python -m http.server --bind 0.0.0.0 --directory $ROBOT_LOG_DIR 3000