Skip to content

Commit

Permalink
Merge pull request #1947 from digitallyinduced/new-docker-build-docs
Browse files Browse the repository at this point in the history
Document creation of Docker with Nix and Podman
  • Loading branch information
mpscholten authored Apr 11, 2024
2 parents 9d52ad2 + 94c0149 commit e100508
Showing 1 changed file with 6 additions and 22 deletions.
28 changes: 6 additions & 22 deletions Guide/deployment.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -313,40 +313,24 @@ IHP has a first party CLI tool called `ihp-app-to-docker-image` to create Docker

### Creating a Docker Image

Assuming your project is using IHP Pro or IHP Business, you can use the `ihp-app-to-docker-image` tool to make a docker image:
To create a Docker image, we first need to install [Podman](https://podman.io/), and then run the following command:

```bash
$ ihp-app-to-docker-image
nix build .#unoptimized-docker-image --option sandbox false --extra-experimental-features nix-command --extra-experimental-features flakes

...
✅ The docker image is at 'docker.tar.gz'
```

The command needs to be called from inside the application directory.

This tool will compile your app and output an docker image at `docker.tar.gz`. The docker image is typically around 85MB in size. If your application has many dependencies declated in the `default.nix` it could also be larger.

On macOS the `ihp-app-to-docker-image` tool requires Docker to be up and running. On linux you use the tool without having docker installed.

You can load the `docker.tar.gz` into your running docker instance using `docker load`:

```bash
$ docker load < docker.tar.gz

8e8f0ea2cd55: Loading layer [==================================================>] 87.73MB/87.73MB
Loaded image: app:g13rks9fb4ik8hnqip2s3ngqq4nq14zw
cat result | podman load
```

Running `docker images` you can now see that the image is available:
Running `podman images` you can now see that the image is available:

```bash
$ docker images

REPOSITORY TAG IMAGE ID CREATED SIZE
app g13rks9fb4ik8hnqip2s3ngqq4nq14zw ffc01de1ec7e 51 years ago 86.6MB
app g13rks9fb4ik8hnqip2s3ngqq4nq14zw ffc01de1ec7e 54 years ago 86.6MB
```

The `CREATED` timestamp is showing `51 years ago` as the image is built using nix. For having a totally reproducable build, the timestamp is set to `Jan 1970, 00:00 UTC`.
The `CREATED` timestamp is showing over 50 years ago as the image is built using nix. For having a totally reproducible build, the timestamp is set to `Jan 1970, 00:00 UTC`.

### Starting the App Container

Expand Down

0 comments on commit e100508

Please sign in to comment.