Skip to content

Commit

Permalink
Add development Dockerfile
Browse files Browse the repository at this point in the history
* Development dockerfile builds from the current source directory
* Add instructions to build and use docker container
  • Loading branch information
HugoKlepsch committed Dec 28, 2017
1 parent 68ec007 commit 6c44324
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 8 deletions.
31 changes: 25 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,36 @@ WORKDIR /home/retdec
ENV HOME /home/retdec

RUN apt-get -y update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential git bc graphviz upx cmake python zlib1g-dev flex bison libtinfo-dev autoconf pkg-config m4 libtool wget
DEBIAN_FRONTEND=noninteractive apt-get install -y \
build-essential \
cmake \
git \
perl \
python3 \
bash \
coreutils \
wget \
bc \
doxygen \
graphviz \
upx \
flex \
bison \
zlib1g-dev \
libtinfo-dev \
autoconf \
automake \
pkg-config \
m4 \
libtool

USER retdec
RUN git clone --recursive https://github.com/avast-tl/retdec && \
cd retdec && \
mkdir build && \
cd build && \
cmake .. -DCMAKE_INSTALL_PREFIX=/home/retdec/retdec-install && \
make && \
cmake .. -DCMAKE_INSTALL_PREFIX=/home/retdec/install && \
make -j$(nproc) && \
make install

ENV PATH /home/retdec/retdec-install/bin:$PATH

CMD ["/bin/bash"]
ENV PATH /home/retdec/install/bin:$PATH
45 changes: 45 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM ubuntu:bionic

RUN useradd -m retdec
WORKDIR /home/retdec
ENV HOME /home/retdec

RUN apt-get -y update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
build-essential \
cmake \
git \
perl \
python3 \
bash \
coreutils \
wget \
bc \
doxygen \
graphviz \
upx \
flex \
bison \
zlib1g-dev \
libtinfo-dev \
autoconf \
automake \
pkg-config \
m4 \
libtool

# New versions of docker (>v17.09.0-ce) support the --chown flag given to COPY
# Once this version is more wide spread, consider updating this repository's Dockerfiles
# to use the new directive.
COPY . retdec
RUN chown -R retdec:retdec retdec

USER retdec
RUN cd retdec && \
mkdir build && \
cd build && \
cmake .. -DCMAKE_INSTALL_PREFIX=/home/retdec/install && \
make -j$(nproc) && \
make install

ENV PATH /home/retdec/install/bin:$PATH
67 changes: 65 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,72 @@ Currently, we support only Windows (7 or later), Linux, and unofficially macOS.
## Build and Installation
### Build in Docker
#### Build image
Building in Docker doesn't require installation of required libraries locally.
This is a good option for trying out retdec without setting up the whole build toolchain.

To build the retdec docker image, run

```
docker build -t retdec .
```
This builds the container from the master branch of this repository.
To build the container using the local copy of the repository, fully clone the repository:
```
git submodule update --init --recursive
```
Then build the container using the development Dockerfile, `Dockerfile.dev`:
```
docker build -t retdec:dev . -f Dockerfile.dev
```
#### Run container
To decompile a binary, create a container to upload the binary to:
```
docker create --name retdec_init retdec
```
Upload the binary:
Note the destination directory should be a directory with read/write permissions
like /home/retdec/.
```
docker cp <file> retdec_init:/destination/path/of/binary
```
Commit the copied files into the container image:
```
docker commit retdec_init retdec:initialized
```
Run the decompiler:
```
docker run --name retdec retdec:initialized decompile.sh /destination/path/of/binary
```
Copy output back to host:
```
docker cp retdec:/destination/path/of/binary.c /path/to/save/file
```
### Build and install locally
This section describes a manual build and installation of RetDec.
### Requirements
#### Requirements
#### Linux
Expand Down Expand Up @@ -142,7 +205,7 @@ sudo dnf install git cmake make gcc gcc-c++ perl python3 bash zlib-devel flex bi
* [wget](https://www.gnu.org/software/wget/)
* [Python](https://www.python.org/) (version >= 3.4, macOS has 2.7)

### Process
#### Process

**Warning: Currently, RetDec has to be installed into a clean, dedicated directory. Do NOT install it into `/usr`, `/usr/local`, etc. because our build system is not yet ready for system-wide installations. So, when running `cmake`, always set `-DCMAKE_INSTALL_PREFIX=<path>` to a directory that will be used just by RetDec. For more details, see [#12](https://github.com/avast-tl/retdec/issues/12).**

Expand Down

0 comments on commit 6c44324

Please sign in to comment.