Skip to content

Commit

Permalink
Reduced docker image size
Browse files Browse the repository at this point in the history
  • Loading branch information
salivian committed Sep 17, 2020
1 parent 3a6a38e commit 9918d2e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 28 deletions.
31 changes: 3 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,12 @@
FROM ubuntu

ENV DEBIAN_FRONTEND "noninteractive"
RUN apt-get update -qq && \
apt-get install --no-install-recommends --no-install-suggests -y \
build-essential git python3-pip python3 nginx && pip3 install --no-cache-dir fastapi uvicorn

RUN git clone https://github.com/laurolins/nanocube.git /nanocube-src

RUN mkdir /data /www
RUN cp -a /nanocube-src/web/dist/* /www

WORKDIR nanocube-src
RUN ./configure --with-polycover --prefix=/nanocube && make && make install


COPY ./docker-app /app

#setup a sample /data

#generate a sample cube
RUN bash -c '/nanocube/bin/nanocube create <(gunzip -c ./data/crime50k.csv.gz) ./data/crime50k.map /data/crime50k.nanocube -header'

#copy the sample configuration
RUN mv /app/config.json /data

#cleanup
RUN rm -rf /nanocube-src && \
apt-get remove --purge -y build-essential git python3-pip && \
apt-get autoremove -y && apt-get clean && \
rm -rf /var/lib/apt/lists/*


#build
RUN /app/build.sh

#run
WORKDIR /app
CMD ["/app/run.sh"]
CMD /app/run.sh
34 changes: 34 additions & 0 deletions docker-app/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
set -x

#install dependencies
apt-get update
apt-get install --no-install-recommends --no-install-suggests -y \
build-essential git nginx ca-certificates

#apt-get install --no-install-recommends --no-install-suggests -y \
# python3-pip python3
#pip3 install --no-cache-dir fastapi uvicorn pandas sqlalchemy

#clone and build
git clone https://github.com/laurolins/nanocube.git /nanocube-src
cd /nanocube-src
export CXXFLAGS=-O2
export CFLAGS=-O2
./configure --with-polycover --prefix=/nanocube
make && make install

#make sample data directories
mkdir /data /www
cp -a /nanocube-src/web/dist/* /www
#sample web config
mv /app/config.json /data

#sample nanocube
cd /nanocube-src
bash -c '/nanocube/bin/nanocube create <(gunzip -c ./data/crime50k.csv.gz) ./data/crime50k.map /data/crime50k.nanocube -header'

#cleanup
rm -rf /nanocube-src
apt-get remove --purge -y build-essential git python3-pip
apt-get autoremove -y && apt-get clean
rm -rf /var/lib/apt/lists/*
5 changes: 5 additions & 0 deletions docker-app/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ events {

http {
include /etc/nginx/mime.types;
gzip on;
proxy_cache_path /tmp/cache keys_zone=mycache:10m;

server {
listen 80;
proxy_cache mycache;

location / {
root /www/;
index index.html;
Expand Down

0 comments on commit 9918d2e

Please sign in to comment.