diff --git a/Dockerfile b/Dockerfile index f3bd20c2fa..2d752430d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,12 +4,12 @@ # Requires 1GB of free disk space # # Build docker image with: -# $ docker build -t r2docker . +# $ docker build -t r2docker:latest . # # Run the docker image: # $ docker images -# $ export DOCKER_IMAGE_ID= docker images | awk '{print $3}'|head -n2 | tail -n1` -# $ docker run -ti ${DOCKER_IMAGE_ID} bash +# $ export DOCKER_IMAGE_ID=$(docker images --format '{{.ID}}' -f 'label=r2docker') +# $ docker run -ti --cap-drop=ALL r2docker:latest # # Once you quit the bash session get the container id with: # $ docker ps -a | grep bash @@ -22,66 +22,78 @@ # $ xz -d < container.xz | docker import - # # -# If you willing to debug a program within Docker, you should run it in privileged mode: +# If you willing to debug a program within Docker, you should run it with CAP_SYS_PTRACE: # -# $ docker run -it --privileged radare/radare2 +# $ docker run -it --cap-drop=ALL --cap-add=SYS_PTRACE r2docker:latest # $ r2 -d /bin/true # -# using phusion/baseimage as base image. -# FROM ubuntu -FROM phusion/baseimage +# Using debian 8 as base image. +FROM debian:8 -# Set correct environment variables. -ENV HOME /root +# Label base +LABEL r2docker latest -# Regenerate SSH host keys. baseimage-docker does not contain any -# RUN /etc/my_init.d/00_regen_ssh_host_keys.sh +# Radare version +ENV R2_VERSION master +# R2pipe python version +ENV R2_PIPE_PY_VERSION 0.8.9 +# R2pipe node version +ENV R2_PIPE_NPM_VERSION 2.3.2 -# Use baseimage-docker's init system. -CMD ["/bin/bash"] +# Build radare2 in a volume to minimize space used by build +VOLUME ["/mnt"] -# create code directory -RUN mkdir -p /opt/code/ -# install packages required to compile vala and radare2 -RUN apt-get update -RUN apt-get upgrade -y -RUN apt-get install -y software-properties-common wget python curl valgrind -RUN apt-get install -y gcc git bison pkg-config make glib-2.0 unzip sudo -#RUN apt-get install -y swig flex bison git gcc g++ make pkg-config glib-2.0 -#RUN apt-get install -y swig flex bison git gcc g++ make pkg-config glib-2.0 -#RUN apt-get install -y python-gobject-dev valgrind gdb +# Install all build dependencies +# Install bindings +# Build and install radare2 on master branch +# Remove all build dependencies +# Cleanup +RUN DEBIAN_FRONTEND=noninteractive dpkg --add-architecture i386 && \ + apt-get update && \ + apt-get install -y \ + curl \ + gcc \ + git \ + bison \ + pkg-config \ + make \ + glib-2.0 \ + libc6:i386 \ + libncurses5:i386 \ + libstdc++6:i386 \ + sudo && \ + curl -sL https://deb.nodesource.com/setup_7.x | bash - && \ + apt-get install -y nodejs python-pip && \ + curl -sL https://www.npmjs.com/install.sh | bash - && \ + pip install r2pipe=="$R2_PIPE_PY_VERSION" && \ + npm install -g "r2pipe@$R2_PIPE_NPM_VERSION" && \ + cd /mnt && \ + git clone -b "$R2_VERSION" --depth 1 https://github.com/radare/radare2.git && \ + cd radare2 && \ + ./sys/install.sh && \ + make install && \ + apt-get remove --purge -y \ + curl \ + gcc \ + git \ + bison \ + pkg-config \ + make \ + python-pip \ + glib-2.0 && \ + apt-get autoremove --purge -y && \ + apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -#ENV VALA_TAR vala-0.32.1 +# Create non-root user +RUN useradd -m r2 && \ + adduser r2 sudo && \ + echo "r2:r2" | chpasswd -# compile vala -#RUN cd /opt/code && \ -## wget -c https://download.gnome.org/sources/vala/0.32/${VALA_TAR}.tar.xz && \ -# shasum ${VALA_TAR}.tar.xz | grep -q 0839891fa02ed2c96f0fa704ecff492ff9a9cd24 && \ -# tar -Jxf ${VALA_TAR}.tar.xz -#RUN cd /opt/code/${VALA_TAR}; ./configure --prefix=/usr ; make && make install -# compile radare and bindings - -# Python -RUN apt-get install -y python-pip ; pip install r2pipe - -# NodeJS -RUN curl -sL https://deb.nodesource.com/setup_7.x | bash - ; apt-get install -y nodejs - -# Clean up APT when done. -RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -# build and install r2 -RUN cd /opt/code ; git clone --depth 1 https://github.com/radare/radare2.git; cd radare2; ./sys/install.sh -RUN cd /opt/code/radare2 ; make symstall - -RUN npm install -g r2pipe - -RUN useradd -m r2 -RUN adduser r2 sudo -RUN (echo r2;echo r2) | passwd r2 +# Initilise base user USER r2 WORKDIR /home/r2 -ENV HOME=/home/r2 +ENV HOME /home/r2 -RUN r2 -V +# Base command for container +CMD ["/bin/bash"]