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

chore: development setup in Docker #1478

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
35 changes: 35 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM node:13.10.1-slim
Copy link

Choose a reason for hiding this comment

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

Why use not use a LTS version? 14.15.4 is the latest LTS.
https://nodejs.org/en/download/releases/


RUN apt-get update
RUN apt-get install -y yarn
RUN apt-get install -y git
RUN apt-get install -y libacl1-dev
RUN apt-get install -y libncurses-dev

#esy install
RUN apt-get install -y curl

#esy bootstrap
RUN apt-get install -y clang
RUN apt-get install -y make
RUN apt-get install -y m4
RUN apt-get install -y nasm
RUN apt-get install -y libfontconfig1-dev
RUN apt-get install -y libx11-dev
RUN apt-get install -y libsdl2-dev
RUN apt-get install -y libbz2-dev
RUN apt-get install -y libgtk-3-dev

RUN apt-get install -y opam
Comment on lines +3 to +23
Copy link

Choose a reason for hiding this comment

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

All apt operations should be put in a single RUN, see: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run

Something like:

RUN apt-get update -q && apt-get install -y --no-install-recommends \
    yarn \
    git \
    …
    …
    …
 && rm -rf /var/lib/apt/lists/*

At the end the apt cache is no longer required and deleted, for a slimmer container image.

Same with the rest of the similar RUN instructions.

RUN opam init
RUN opam install dune

RUN yarn global add [email protected]

WORKDIR /code

RUN esy install
RUN esy bootstrap
RUN esy build

CMD esy run
Copy link

Choose a reason for hiding this comment

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

On the CMD instruction, it is preferred to use arguments JSON notation.
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#cmd
https://github.com/hadolint/hadolint/wiki/DL3025

CMD ["esy", "run"]

14 changes: 14 additions & 0 deletions docs/docs/for-developers/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,17 @@ From the `oni2` directory:
- `cd docs/website`
- `npm install`
- `npm start`

### Docker

```bash
docker build --network=host -t oni2-dev -f Dockerfile.dev .
# Creates a 12GB image !!!

docker run -it \
Copy link

Choose a reason for hiding this comment

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

👏🏼

-v ${PWD}:/code \
-v "$HOME/.Xauthority:/root/.Xauthority:rw" \
--network=host \
--env="DISPLAY" \
oni2-dev
```