Skip to content

Commit

Permalink
Update Docker build process
Browse files Browse the repository at this point in the history
This updates the Docker build process to account for all the recent
changes. We're also back to using a .dockerignore file again, as the
slowdown this used to introduced was fixed a while back.

Changelog: changed
  • Loading branch information
yorickpeterse committed Sep 8, 2022
1 parent 3ce1b41 commit c454fd4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
@@ -0,0 +1,11 @@
.git/
CHANGELOG.md
clippy.toml
deny.toml
docs/
gitlint
libstd/build/
macstadium.png
scripts/
target/
tmp/
18 changes: 3 additions & 15 deletions Dockerfile
@@ -1,28 +1,16 @@
FROM alpine:3 AS builder

RUN apk add --update make libffi libffi-dev rust cargo build-base

# Per https://github.com/containers/buildah/issues/1849#issuecomment-635579332,
# the presence of a .dockerignore slows down the build process. To work around
# this, we add the necessary files/directories explicitly, instead of using
# `ADD . /inko/` to add files.
ADD Cargo.lock Cargo.toml LICENSE Makefile /inko/
ADD .cargo /inko/.cargo/
ADD ast /inko/ast/
ADD bytecode /inko/bytecode/
ADD compiler /inko/compiler/
ADD libstd/src /inko/compiler/libstd/src
ADD vm /inko/vm

ADD . /inko/
WORKDIR /inko
RUN make build FEATURES='libffi-system' PREFIX='/usr'
RUN make build FEATURES=libffi-system PREFIX='/usr'
RUN strip target/release/inko
RUN make install PREFIX='/usr'

FROM alpine:3

# libgcc is needed because libgcc is dynamically linked to the executable.
RUN apk add --update libffi libffi-dev ruby ruby-json libgcc
RUN apk add --update libffi libffi-dev libgcc

COPY --from=builder ["/usr/bin/inko", "/usr/bin/inko"]
COPY --from=builder ["/usr/lib/inko", "/usr/lib/inko/"]
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -62,7 +62,7 @@ SOURCE_TAR := ${TMP_DIR}/${VERSION}.tar.gz
MANIFEST := ${TMP_DIR}/manifest.txt

build:
INKO_LIBSTD=${INSTALL_STD} cargo build --release
INKO_LIBSTD=${INSTALL_STD} cargo build --release ${FEATURES_OPTION}

${TMP_DIR}:
mkdir -p "${@}"
Expand Down Expand Up @@ -161,7 +161,7 @@ docs/versions:

clippy:
touch */src/lib.rs */src/main.rs
cargo clippy ${FEATURES_OPTION} -- -D warnings
cargo clippy -- -D warnings

rustfmt-check:
rustfmt --check */src/lib.rs */src/main.rs
Expand Down
6 changes: 6 additions & 0 deletions docs/source/getting-started/installation.md
Expand Up @@ -179,6 +179,12 @@ variable.
When packaging Inko it's best to use a system wide installation of FFI, instead
of building it from source when compiling Inko. To do so, build Inko as follows:

```bash
make build FEATURES=libffi-system
```

Or if you don't want to use make:

```bash
cargo build --release --features libffi-system
```
Expand Down

0 comments on commit c454fd4

Please sign in to comment.