Giter Site home page Giter Site logo

idris-2-docker's Introduction

Idris 2 Docker

Multi-arch, multi-distro Docker images for Idris 2, primarily aimed for devcontainers.

Architectures: amd64, arm64

Idris Versions: v0.5.1, v0.6.0, v0.7.0, latest (Up to date with Idris2/main - recompiled daily)

Table of Contents

Motivation

Installing Idris2 is quite time consuming and not very intuitive, especially for Apple Silicon. That presents quite a bottleneck for new users. This project aims to provide a quick and easy way to get started with Idris2 without having to go through the entire process on your own machine.

Images

Example Project

An example Hello World project taken from the Getting Started Guide can be found in example. It uses Idris 0.7.0. To start, clone this repo and open the example folder (not the root!) in VSCode.

git clone [email protected]:joshuanianji/idris-2-docker.git
cd idris-2-docker/example
code .

Usage

Devcontainer

Add devcontainers to your own project by copying the following contents to Dockerfile in the root of your project:

FROM ghcr.io/joshuanianji/idris-2-docker/devcontainer:v0.7.0

Then, using Microsoft's Remote SSH tools, click "Reopen in container" and choose that Dockerfile.

Command Line

You can also run the image directly from the command line.

docker run -it --rm ghcr.io/joshuanianji/idris-2-docker/ubuntu:v0.5.1 idris2 --version
Idris 2, version 0.5.1

docker run -it --rm --entrypoint /bin/bash ghcr.io/joshuanianji/idris-2-docker/debian:v0.5.1
$ idris2 --version

Base Image

You can also use one of the images as a base image for your own Dockerfile.

FROM ghcr.io/joshuanianji/idris-2-docker/debian:v0.5.1

# ...

Running Locally

To run the images locally, I recommend opening the workspace in the Devcontainer to provide a fully-featured development environment. I made a scripts/build-image.py which can build the base, debian, ubuntu or devcontainer from an idris version or a SHA commit.

Build Latest

This is the default behaviour when running the script.

# builds base from latest commit on the Idris repo. Tag is base-latest
python scripts/build-image.py --image base
python scripts/build-image.py --image devcontainer --tag devcontainer-latest-test

Build From a Tagged Release/SHA commit

python scripts/build-image.py --image base --version v0.6.0
python scripts/build-image.py --image base --sha 58e5d156621cfdd4c54df26abf7ac9620cfebdd8
python scripts/build-image.py --image devcontainer --version v0.6.0

Credit

idris-2-docker's People

Contributors

dependabot[bot] avatar jiwhiz avatar joshuanianji avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jiwhiz kamweti

idris-2-docker's Issues

Devcontainers: Run as non-root user

People often need to run their devcontainers as a non-root user.

This mitigates issues such as Docker overriding file ownerships in Linux which lead to some tricky errors down the line (especially with git). Currently, using a non-root user in devcontainers makes the idris2 binaries not available to the user (bash: idris2: command not found).

I think an approach similar to #16 should be the default installation for devcontainers, where the idris2 files are installed to /usr/local/lib/idris2.

Local Build Documentation

I had the idea that all builds would be on Github Actions, but adding documentation for locally building the image would improve other peoples' abilities to contribute.

Remove `ENTRYPOINT` in Consumer Images

I think ENTRYPOINT is a bit too limiting for the type of images I'm making, since i'm often finding myself overriding the entrypoint when doing stuff with the debian or ubuntu images.

Using CMD is easier to override, but do I even need one? Maybe the default shell is enough...

Ubuntu and Debian tests

I like the test setup we had for the Devcontainers in #25 using Bats. I think having something similar just to test that the Idris binary is working in the Ubuntu and Debian images is a good idea.

Use Chez Scheme

Currently I'm using Racket, and this is apparently a bit slower. Not sure if this is the reason for the incredibly slow builds on Github actions, though.

We can use the Racket fork if Chez Scheme for better performance (i think). Not sure about any other limitations. Based on this comment.

`IDRIS_SHA` and `IDRIS_LSP_SHA` not populating

For latest builds, the IDRIS_SHA and IDRIS_LSP_SHA are not being populated. This is a pretty sneaky bug because the LSP and Idris2 base image still succeeds. I might want to make a test that the $IDRIS_SHA env vars are nonempty.

Version 0.6.0

Build are failing with Version 0.6.0, will have to look into

Install idris2-lsp

The VS Code extension zjhmale.Idris is out of date, and for Idris2, we are using idris2-lsp, with Visual Studio Code extension idris2-lsp-vscode

You can follow the instruction of Manual Installation to install idris2 and idris2-lsp.

I suggest to only work on latest now, ignore idris2 release 0.5.0 and 0.5.1, because there is no idris2-lsp releases.

Devcontainer - Update Docs

Now that #25 has been merged, we should update our docs and decontainer examples to have non-root users. Maybe also update Caleb's WordleInIdris example?

Base image missing the Idris2 api package

To Reproduce

install: install-idris2 install-support install-libs

https://github.com/idris-lang/Idris2/blob/main/Makefile#L188

  • building a library such as idris2-python against the base image fails with
required idris2 any but no matching version is installed
  • the missing dependency is
depends = idris

https://github.com/madman-bob/idris2-python/blob/main/idris2-python.ipkg#L5

  • this bug can be resolved by installing the api package
make install-api

Expected behavior

base image should explicitly install api package

Devcontainer Image Updates

CI is failing in 0af80fe because the LSP hasn't updated to the latest release yet (see: idris-community/idris2-lsp#187)


In the meantime, we can improve the devcontainer image. Currently, we use a simple git clone command. This means that, even in a 0.4.0 release build, we will pull from the latest (possibly cached) commit. It would be better to ensure the LSP and Idris versions are the same.

The LSP has branches for versions 0.4.0, 0.5.1 and 0.6.0, so if I remove my 0.5.0 tag (which seems like a good idea), I can make use of git checkout to switch branches and sync versions with the LSP.

Note that latest will still not work until the LSP merges the PR.


One other improvement is the addition of tests to the devcontainer image, so we have an added layer of security that it actually works lol.

Since the Devcontainer operates on its own version of idris (managed by the submodule in the LSP github), and we only need the Scheme dependency from the base image, we should be able to test this independently.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

devcontainer
.devcontainer.json
  • mcr.microsoft.com/devcontainers/python 1-3.11-bullseye
  • ghcr.io/devcontainers/features/common-utils 2
  • ghcr.io/devcontainers/features/docker-in-docker 2
  • ghcr.io/devcontainers/features/github-cli 1
  • ghcr.io/edouard-lopez/devcontainer-features/bats 0
  • ghcr.io/joshuanianji/devcontainer-features/github-cli-persistence 1
dockerfile
base-sha.Dockerfile
  • debian bullseye
  • debian bullseye
base.Dockerfile
  • debian bullseye
  • debian bullseye
debian.Dockerfile
  • debian bullseye
devcontainer-sha.Dockerfile
  • debian bullseye
devcontainer.Dockerfile
  • debian bullseye
ubuntu.Dockerfile
  • ubuntu 20.04
github-actions
.github/actions/build-base-img/action.yml
  • docker/build-push-action v6
  • docker/build-push-action v6
.github/actions/build-devcontainer-img/action.yml
  • docker/build-push-action v6
  • docker/build-push-action v6
.github/workflows/version-base-build-test.yml
  • actions/checkout v4
  • MrSquaare/ssh-setup-action v3
  • docker/setup-buildx-action v3
  • actions/checkout v4
  • docker/setup-buildx-action v3
  • bats-core/bats-action 2.0.0
  • actions/checkout v4
  • docker/setup-buildx-action v3
  • actions/checkout v4
  • docker/setup-buildx-action v3
  • docker/build-push-action v6
  • bats-core/bats-action 2.0.0
  • registry 2
.github/workflows/version-base-deploy.yml
  • actions/checkout v4
  • MrSquaare/ssh-setup-action v3
  • docker/setup-buildx-action v3
  • docker/login-action v3
  • docker/metadata-action v5
  • actions/checkout v4
  • docker/setup-qemu-action v3
  • docker/setup-buildx-action v3
  • docker/login-action v3
  • docker/metadata-action v5
  • docker/build-push-action v6
.github/workflows/version-devcontainer-build-test.yml
  • actions/checkout v4
  • docker/setup-buildx-action v3
  • bats-core/bats-action 2.0.0
  • registry 2
.github/workflows/version-devcontainer-deploy.yml
  • actions/checkout v4
  • MrSquaare/ssh-setup-action v3
  • docker/setup-buildx-action v3
  • docker/login-action v3
  • docker/metadata-action v5

  • Check this box to trigger a request for Renovate to run again on this repository

Way to move the libraries out of /root

Hi ๐Ÿ‘‹ ,

Thanks for your excellent work!

I am looking for a way to move the libraries out of /root, but constantly run into the following error when launching idris:

Uncaught error: Error: Module Prelude not found

Do you know if recompiling is necessary or I'm just missing some environment configuration?

In the meanwhile I just change owner of the /root directory in my container: https://gitlab.com/niklashh/idris2-toolbox

Better CI Architecture

The current architecture for CI builds is a bit fragile and a lot of fail fast errors happen to jobs that are not tied to each other.

I think I should split up the matrix and single builds (i.e. cron and push builds)

Version tags are getting messed up

Instead of using v0.5.1, v0.6.0, and latest, I removed the "v" suffix to add flexibility, as the version tags in the Idris LSP uses the format Idris2-0.5.1.

But, the way I implemented this means I'll upload and retrieve vlatest tags, which is not desired.

Maybe I need to separate the tag versions for the devcontainer CI builds? This is possible, because the devcontainer doesn't really rely on a specific version of base, since it only imports the scheme libs.

Install Idris2 LSP on Devcontainers

The support for Idris 2 on VSCode comes from the Idris 2 LSP VSCode, which in turn needs Idris 2 Language Server.

Adding this library to the devcontainer will allow for a better developer experience.

Installing this might be a bit tricky since the Idris 2 LSP has its own version of Idris (as a git submodule). We might need to refactor the devcontainer image then (to not import Idris2 build files).
Looking at the Manual Installation, they word it as if installing it from source (which is what we did) ensures we don't need to uninstall idris2. Will need further investigation.

CI/CD Pipeline Refactoring

Currently, all packages republishes every single version during the cron job. This is pretty annoying; I should only publish latest during cron.

Also, I can slightly improve the pipeline structure by not making the consumer-build-test and devcontainer-build-test dependant on the base-deploy. This puts a subtle dependency on the Github Container registry uploading the new base image fast enough, which feels like a bad design.

I think I should pass the base image around via github artifacts, and change the FROM step to import the entire image from a argument. For arm builds this might introduce complexity when referencing images, so I'll have to be careful.

This might result in another full scale refactoring...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.