-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
143 lines (130 loc) · 4.95 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# FROM stackql/stackql:latest AS stackql
# EXPOSE 5444
# WORKDIR /home/stackql
# RUN adduser --system --uid 1001 stackql
# RUN addgroup --system --gid 1001 stackql
# RUN chown stackql:stackql /home/stackql
# RUN chown stackql:stackql /srv
# USER stackql
# # pull stackql providers
# RUN stackql exec 'registry pull aws' || (echo "Failed to pull aws provider" && exit 1)
# RUN stackql exec 'registry pull google' || (echo "Failed to pull google provider" && exit 1)
# RUN stackql exec 'registry pull github' || (echo "Failed to pull github provider" && exit 1)
# RUN stackql exec 'registry pull azure' || (echo "Failed to pull azure provider" && exit 1)
# # RUN stackql exec 'registry pull k8s'
# # RUN stackql exec 'registry pull netlify'
# # RUN stackql exec 'registry pull okta'
# # RUN stackql exec 'registry pull sumologic'
# # RUN stackql exec 'registry pull digitalocean'
# FROM jupyter/base-notebook:latest AS jupyter
# WORKDIR /jupyter
# USER root
# RUN apt-get update && \
# apt-get upgrade -y
# # copy example notebooks to Jupyter workspace
# COPY ./notebooks/ /jupyter/
# RUN chmod 644 *.ipynb && \
# chown jovyan:users *.ipynb
# # copy magic extensions
# RUN mkdir -p /jupyter/ext
# COPY ./extensions/* /jupyter/ext
# RUN chmod 644 /jupyter/ext/*.py && \
# chown jovyan:users /jupyter/ext/*.py
# # copy entrypoint script
# RUN mkdir -p /scripts
# COPY ./scripts/start-server.sh /scripts
# COPY ./scripts/entrypoint.sh /scripts
# RUN chmod +x /scripts/start-server.sh
# RUN chmod +x /scripts/entrypoint.sh
# # set up matplotlib temp dir
# RUN mkdir -p /tmp/matplotlib
# RUN chmod 777 /tmp/matplotlib
# ENV MPLCONFIGDIR=/tmp/matplotlib
# ENV PYDEVD_DISABLE_FILE_VALIDATION=1
# # setup python environment
# ENV PYTHON_PACKAGES="\
# pystackql>=3.6.4 \
# matplotlib \
# pandas \
# mplfinance \
# psycopg2-binary \
# nest_asyncio \
# plotly \
# ipytree \
# nbformat \
# networkx \
# "
# RUN pip install --upgrade pip \
# && pip install --no-cache-dir $PYTHON_PACKAGES
# # copy stackql providers from stackql container
# COPY --from=stackql /home/stackql/.stackql /jupyter/.stackql
# RUN ls -al /jupyter/.stackql/src/aws || (echo "aws provider not present" && exit 1)
# RUN ls -al /jupyter/.stackql/src/googleapis.com || (echo "google provider not present" && exit 1)
# RUN ls -al /jupyter/.stackql/src/github || (echo "github provider not present" && exit 1)
# # copy stackql binary from stackql container (service instance)
# COPY --from=stackql /srv/stackql/stackql /srv/stackql/stackql
# Stage 1: StackQL setup
FROM stackql/stackql:latest AS stackql
EXPOSE 5444
WORKDIR /home/stackql
RUN adduser --system --uid 1001 stackql
RUN addgroup --system --gid 1001 stackql
RUN chown stackql:stackql /home/stackql
RUN chown stackql:stackql /srv
USER stackql
# Pull stackql providers
RUN stackql exec 'registry pull aws' || (echo "Failed to pull aws provider" && exit 1)
RUN stackql exec 'registry pull google' || (echo "Failed to pull google provider" && exit 1)
RUN stackql exec 'registry pull github' || (echo "Failed to pull github provider" && exit 1)
RUN stackql exec 'registry pull azure' || (echo "Failed to pull azure provider" && exit 1)
# Stage 2: Jupyter setup
FROM jupyter/base-notebook:latest AS jupyter
WORKDIR /jupyter
USER root
RUN apt-get update && \
apt-get upgrade -y
# Copy example notebooks to Jupyter workspace
COPY ./notebooks/ /jupyter/
RUN chmod 644 /jupyter/*.ipynb && \
chown jovyan:users /jupyter/*.ipynb
# Copy magic extensions
RUN mkdir -p /jupyter/ext
COPY ./extensions/* /jupyter/ext/
RUN chmod 644 /jupyter/ext/*.py && \
chown jovyan:users /jupyter/ext/*.py
# Copy entrypoint script
RUN mkdir -p /scripts
COPY ./scripts/start-server.sh /scripts
COPY ./scripts/entrypoint.sh /scripts
RUN chmod +x /scripts/start-server.sh /scripts/entrypoint.sh
# Set up matplotlib temp dir
RUN mkdir -p /tmp/matplotlib
RUN chmod 777 /tmp/matplotlib
ENV MPLCONFIGDIR=/tmp/matplotlib
ENV PYDEVD_DISABLE_FILE_VALIDATION=1
# Setup python environment
ENV PYTHON_PACKAGES="\
pystackql>=3.6.4 \
matplotlib \
pandas \
mplfinance \
psycopg2-binary \
nest_asyncio \
plotly \
ipytree \
nbformat \
networkx \
"
RUN pip install --upgrade pip && pip install --no-cache-dir $PYTHON_PACKAGES
# Copy stackql providers and binary from stackql container
COPY --from=stackql /home/stackql/.stackql /jupyter/.stackql
COPY --from=stackql /srv/stackql/stackql /srv/stackql/stackql
# Ensure providers are present
RUN ls -al /jupyter/.stackql/src/aws || (echo "aws provider not present" && exit 1)
RUN ls -al /jupyter/.stackql/src/googleapis.com || (echo "google provider not present" && exit 1)
RUN ls -al /jupyter/.stackql/src/github || (echo "github provider not present" && exit 1)
# Set user back to default jovyan
USER jovyan
# Set entrypoint
# ENTRYPOINT ["/scripts/entrypoint.sh"]
# CMD ["start-notebook.sh"]