Skip to content
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
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*
!Dockerfile
!.dockerignore
!cabal.project
!openleetcode.cabal
!cli/
!cli/**
!core/
!core/**
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,36 @@ jobs:

Copy-Item $exe.FullName "artifacts/${{ matrix.artifact }}.exe"

- name: Smoke test executable
if: runner.os != 'Windows'
run: |
./artifacts/${{ matrix.artifact }} --version

- name: Smoke test executable
if: runner.os == 'Windows'
shell: pwsh
run: |
.\artifacts\${{ matrix.artifact }}.exe --version

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: artifacts/*
if-no-files-found: error

build-container:
name: Build container
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build image
run: docker build -t openleetcode:test .

- name: Smoke test
run: docker run --rm openleetcode:test --version

discover-test-ranges:
name: Discover test ranges
runs-on: ubuntu-latest
Expand Down
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM haskell:9.8-slim-bullseye AS build

WORKDIR /src

COPY cabal.project openleetcode.cabal ./
COPY cli ./cli
COPY core ./core

RUN cabal update \
&& cabal build exe:openleetcode \
&& exe="$(find dist-newstyle -type f -path '*/x/openleetcode/build/openleetcode/openleetcode' | head -n 1)" \
&& test -n "$exe" \
&& install -D "$exe" /out/openleetcode

FROM debian:bullseye-slim

LABEL org.opencontainers.image.source="https://github.com/therepanic/openleetcode"

RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates libgmp10 \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY --from=build /out/openleetcode /usr/local/bin/openleetcode

ENTRYPOINT ["openleetcode"]
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ $ openleetcode submit ./solution.rs --title two-sum

## Install

You need Docker for the execution backend. On Linux and macOS the installer will try to start the default Piston backend for you through Docker Compose.
You need Docker for the execution backend. On Linux and macOS the installer will try to start the default Piston backend for you through Docker Compose. On Windows, the installer only installs the CLI. Bring Docker yourself and start the backend manually.

Linux and macOS:

Expand All @@ -45,7 +45,16 @@ Windows PowerShell:
irm https://raw.githubusercontent.com/therepanic/openleetcode/main/install.ps1 | iex
```

On Windows, the installer only installs the CLI. Bring Docker yourself and start the backend manually.
Docker:

```sh
curl -fsSL https://raw.githubusercontent.com/therepanic/openleetcode/main/openleetcode.yml -o openleetcode.yml
curl -fsSL https://raw.githubusercontent.com/therepanic/openleetcode/main/backends/piston/docker-compose.yml -o piston.yml
docker compose -f piston.yml up -d
docker compose -f openleetcode.yml -f piston.yml run --rm openleetcode --version
```

The backend may take a while to install runtimes on the first start.

## Backend

Expand Down
4 changes: 4 additions & 0 deletions backends/piston/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
services:
piston:
image: ghcr.io/engineer-man/piston:latest
networks:
default:
aliases:
- backend
container_name: piston
restart: unless-stopped
privileged: true
Expand Down
13 changes: 13 additions & 0 deletions openleetcode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
openleetcode:
image: ghcr.io/therepanic/openleetcode:latest
stdin_open: true
tty: true
volumes:
- ./:/app
- openleetcode_data:/root/.config/openleetcode
environment:
OPENLEETCODE_BACKEND_URL: "http://backend:2000"

volumes:
openleetcode_data:
Loading