-
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.
Merge pull request #2 from dinkelk/dockerfile
adding docker environment for running and building redo
- Loading branch information
Showing
11 changed files
with
142 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
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 @@ | ||
# | ||
# This Dockerfile needs to be run from within the project/ directory (AKA ../../ from here) | ||
# so that docker has access to all the files it needs. ie. | ||
# | ||
# $ docker build -t $DOCKER_IMAGE_NAME -f redo/docker/Dockerfile . | ||
# | ||
# For best results use the ./build_image.sh and ./create_container.sh scripts | ||
# provided in this directory. | ||
# | ||
FROM ubuntu:22.04 AS base | ||
LABEL org.opencontainers.image.source=https://github.com/dinkelk/redo | ||
LABEL org.opencontainers.image.description="Development environment for redo" | ||
LABEL org.opencontainers.image.licenses=MIT | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# install common dependencies | ||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -yq install \ | ||
software-properties-common \ | ||
apt-utils \ | ||
locales \ | ||
curl \ | ||
lsb-release \ | ||
sudo \ | ||
python3 \ | ||
git \ | ||
build-essential \ | ||
cmake \ | ||
hlint \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get -yq clean | ||
|
||
# ensure we have the en_US.UTF-8 locale available | ||
RUN locale-gen en_US.UTF-8 | ||
RUN rm /etc/apt/apt.conf.d/docker-clean | ||
|
||
# Install redo: | ||
ENV STACK_ROOT=/root/.stack | ||
RUN DEBIAN_FRONTEND=noninteractive sudo apt-get install -yq wget \ | ||
&& wget -qO- https://get.haskellstack.org/ | sh \ | ||
&& git config --global core.autocrlf false \ | ||
&& git clone https://github.com/dinkelk/redo.git /root/redo \ | ||
&& /root/redo/do /root/redo/all | ||
|
||
# Add redo to the root user's path | ||
RUN echo 'export PATH="/root/redo/bin:$PATH"' >> /root/.bashrc | ||
|
||
# Make sure user is root at end. | ||
USER root |
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,32 @@ | ||
# docker | ||
|
||
The Dockerfile in this directory contains an environment with `redo` already installed, if you want to quickly try it out. The container also includes the [Haskell Tool Stack](https://docs.haskellstack.org/en/stable/install_and_upgrade/), so you can make modifications and recompile `redo` easily. | ||
|
||
To create the container, first install [Docker Desktop](https://www.docker.com/products/docker-desktop/), then run: | ||
|
||
``` | ||
$ ./create_container.sh | ||
``` | ||
|
||
Once the container is built, you can log into the container by running. | ||
|
||
``` | ||
$ ./login_container.sh | ||
``` | ||
|
||
`redo` will already be included in the build path. | ||
|
||
The container can be started or stopped via: | ||
|
||
``` | ||
$ ./start_container.sh | ||
$ ./stop_container.sh | ||
``` | ||
|
||
and the image can be recreated from scratch by running: | ||
|
||
``` | ||
$ ./build_image.sh | ||
``` | ||
|
||
Enjoy. |
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,7 @@ | ||
#!/bin/sh | ||
|
||
. ./docker_config.sh | ||
# Execute the docker machine from the project/ directory so that we have access | ||
cd ../.. | ||
execute "docker build --no-cache --progress=plain -t $DOCKER_IMAGE_NAME -f redo/docker/Dockerfile ." | ||
cd - >/dev/null |
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,17 @@ | ||
#!/bin/sh | ||
|
||
# Create the docker container with a bind mount: | ||
echo "Creating container..." | ||
. ./docker_config.sh | ||
|
||
execute "docker run -d \ | ||
--name $DOCKER_CONTAINER_NAME \ | ||
--mount type=bind,source=\"$(pwd)\"/../..,target=/share \ | ||
$DOCKER_IMAGE_NAME \ | ||
sleep infinity" | ||
|
||
echo "Finished creating container \"$DOCKER_CONTAINER_NAME\"." | ||
execute "docker ps -a" | ||
|
||
echo "" | ||
echo "Run ./login_container.sh to log in." |
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,12 @@ | ||
#!/bin/sh | ||
|
||
DOCKER_CONTAINER_NAME="redo_container" | ||
DOCKER_IMAGE_NAME="ghcr.io/dinkelk/redo:latest" | ||
export DOCKER_CONTAINER_NAME | ||
export DOCKER_IMAGE_NAME | ||
|
||
# Helper function to print out command as executed: | ||
execute () { | ||
echo "$ $@" | ||
eval "$@" | ||
} |
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,5 @@ | ||
#!/bin/sh | ||
|
||
. ./docker_config.sh | ||
|
||
execute "docker exec -it -u root $DOCKER_CONTAINER_NAME //bin//bash" |
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,4 @@ | ||
#!/bin/sh | ||
|
||
. ./docker_config.sh | ||
execute "docker push $DOCKER_IMAGE_NAME" |
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,5 @@ | ||
#!/bin/sh | ||
|
||
. ./docker_config.sh | ||
execute "docker rm $DOCKER_CONTAINER_NAME" | ||
execute "docker ps -a" |
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,5 @@ | ||
#!/bin/sh | ||
|
||
. ./docker_config.sh | ||
execute "docker start $DOCKER_CONTAINER_NAME" | ||
execute "docker ps -a" |
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,5 @@ | ||
#!/bin/sh | ||
|
||
. ./docker_config.sh | ||
execute "docker stop $DOCKER_CONTAINER_NAME" | ||
execute "docker ps -a" |