forked from emina/rosette
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Docker image and continuous deployment for it (emina#219)
* Add Docker image and continuous deployment for it * Implement suggestions by @lukenels & @jamesbornholt * Cleanup unused comments * ensure `expeditor` is available for the REPL
- Loading branch information
Showing
3 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Docker | ||
|
||
on: | ||
push: | ||
tags: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Clone Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Configure Docker Metadata | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: ghcr.io/${{ github.repository }} | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
- name: Authenticate to Package Registry | ||
uses: docker/login-action@v1 | ||
if: ${{ github.event_name != 'pull_request' }} | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Build and Publish Rosette Image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
FROM alpine:3.15 | ||
|
||
## ========================== [ Install Racket ] =========================== ## | ||
|
||
## Define default Racket version and variant. The Racket version is of the form | ||
## <major>.<minor>. The variant can be "cs" (Chez Scheme), "bc" (Before Chez) or | ||
## "natipkg" (where external libraries are included in the Racket packages). | ||
## | ||
ARG RACKET_VERSION=8.4 | ||
ARG RACKET_VARIANT=cs | ||
|
||
## Install Racket. We first install system dependencies: [gcompat] is needed for | ||
## Racket and [ncurses] is needed for the [xrepl] and [expeditor] packages, | ||
## providing the REPL. We then download the installer, run it with the right | ||
## parameters, then remove it. After that, all that remains is to set-up the | ||
## Racket packages and install [expeditor]. See later for a description of the | ||
## arguments to [raco pkg install]. | ||
## | ||
RUN apk add --no-cache gcompat ncurses | ||
RUN wget "https://download.racket-lang.org/installers/${RACKET_VERSION}/racket-minimal-${RACKET_VERSION}-x86_64-linux-${RACKET_VARIANT}.sh" | ||
RUN echo 'yes\n1\n' | sh racket-minimal-${RACKET_VERSION}-x86_64-linux-${RACKET_VARIANT}.sh --create-dir --unix-style --dest /usr/ | ||
RUN rm racket-minimal-${RACKET_VERSION}-x86_64-linux-${RACKET_VARIANT}.sh | ||
RUN raco setup --no-docs | ||
RUN raco pkg install -i --batch --auto --no-docs expeditor-lib | ||
|
||
## =================== [ Install Rosette's Dependencies ] =================== ## | ||
|
||
## Work on Rosette's installation within /usr/local. This directory will be | ||
## cleaned up later on so it could be anything. | ||
## | ||
WORKDIR /usr/local/rosette | ||
|
||
## Get all the info.rkt files. Trying to install Rosette based only on these | ||
## files would fail, but we can use them to only install dependencies. | ||
## | ||
COPY info.rkt . | ||
COPY rosette/info.rkt rosette/ | ||
|
||
## Install only Rosette's dependencies. We have to install the external | ||
## dependencies [libstdc++] and [libgcc] because Z3 needs them at runtime. As | ||
## for the Racket dependencies only, we achieve that in three steps: | ||
## | ||
## 1. We use [raco pkg install --no-setup] to download and register Rosette | ||
## and all its dependencies without setting them up, that is without | ||
## compiling them. At this point, the system is in an inconsistent state, | ||
## where packages are registered but not actually present. The other flags | ||
## are the following: | ||
## | ||
## -i install packages for all users | ||
## --batch disable interactive mode and suppress prompts | ||
## --auto download missing packages automatically | ||
## | ||
## 2. We use [raco pkg remove --no-setup] to unregister Rosette. This keeps | ||
## the dependencies as registered. The system is still in an inconsistent | ||
## state. See above for the flags. | ||
## | ||
## 3. We use [raco setup] to set up all the registered package. This brings | ||
## the system back in a consistent state. Since Rosette's dependencies were | ||
## registered but not Rosette itself, this achieves our goal. The flags are | ||
## the following: | ||
## | ||
## --fail-fast fail on the first error encountered | ||
## --no-docs do not compile the documentations | ||
## | ||
RUN apk add --no-cache libstdc++ libgcc | ||
RUN raco pkg install -i --batch --auto --no-setup ../rosette | ||
RUN raco pkg remove -i --no-setup rosette | ||
RUN raco setup --fail-fast --no-docs | ||
|
||
## ========================== [ Install Rosette ] =========================== ## | ||
|
||
## Get all of Rosette; build and install it. The dependencies should all be | ||
## installed, so we can remove the --auto flag which will lead us to failure if | ||
## a dependency cannot be found. The additional flags are the following: | ||
## | ||
## --copy copy content to install path (instead of linking) | ||
## | ||
COPY . . | ||
RUN raco pkg install -i --batch --copy --no-docs ./rosette | ||
RUN rm -R /usr/local/rosette | ||
|
||
## ===================== [ Prepare Clean Entry Point ] ====================== ## | ||
|
||
## For further use of the image, we can start with user `rosette`, group | ||
## `rosette` in `/rosette` by default. | ||
## | ||
RUN addgroup rosette | ||
RUN adduser --system --shell /bin/false --disabled-password \ | ||
--home /rosette --ingroup rosette rosette | ||
RUN chown -R rosette:rosette /rosette | ||
USER rosette | ||
WORKDIR /rosette | ||
|
||
## Rosette files are simply Racket files using the Rosette library: the default | ||
## entry point of this image is therefore the Racket executable. | ||
## | ||
ENTRYPOINT ["/usr/bin/racket", "-I", "rosette"] |