Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfiles and instructions for using docker containers #60

Merged
merged 3 commits into from
Jan 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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

USER retdec
RUN git clone --recursive https://github.com/avast-tl/retdec && \
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
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please unify the use of tabs vs spaces? Dockerfile uses tabs for indentation, but Dockerfile.dev uses spaces. I suggest converting spaces in Dockerfile.dev to tabs so both dockerfiles use the same indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


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