Skip to content

Commit

Permalink
feat: add Dockerfile and dock script
Browse files Browse the repository at this point in the history
  • Loading branch information
PatricioIribarneCatella committed Apr 25, 2024
1 parent 96c0da9 commit 17378df
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sched/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ubuntu:16.04

RUN apt-get update && apt-get -y install \
git make gdb python3-dev \
libbsd-dev libc6-dev gcc-multilib linux-libc-dev \
seabios qemu-system-x86

WORKDIR /sched
12 changes: 12 additions & 0 deletions sched/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ make <target> USE_PR=1
make grade
```

## Docker

Se provee un _script_ `dock` que permite ejecutar los siguientes comandos:

- **build**: genera la imagen del proyecto usando el `Dockerfile` provisto
- **run**: genera un _container_ a partir de la imagen anterior y lo corre
- **exec**: permite abrir una nueva _shell_ en el _container_ anterior

Dentro del _container_ se pueden ejecutar todos los comandos provistos por el `GNUmakefile` como `make grade` o `make qemu-nox`.

El _container_ utiliza [mount volumes](https://docs.docker.com/storage/volumes/) con lo cual los cambios que se realicen por fuera del mismo, serán visibles de forma automática.

## Linter

```bash
Expand Down
49 changes: 49 additions & 0 deletions sched/dock
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash

##
## Usage: dock {build|run|exec}
##

DOCKER="docker"
EXEC_CMD="exec"
BUILD_CMD="build"
RUN_CMD="container run"
CONTAINER_NAME="sched"
IMAGE_NAME="fisop-sched"

usage() {
echo "Usage: $0 {build|run|exec}"
exit 1
}

build_container() {
$DOCKER $BUILD_CMD -t $IMAGE_NAME -f Dockerfile .
}

run_container() {
$DOCKER $RUN_CMD -it --rm --name=$CONTAINER_NAME -v $(pwd):/sched $IMAGE_NAME bash
}

exec_container() {
$DOCKER $EXEC_CMD -it $CONTAINER_NAME bash
}

main() {
case $1 in
"build")
build_container
;;
"run")
run_container
;;
"exec")
exec_container
;;
*)
usage
;;
esac

}

main $1

0 comments on commit 17378df

Please sign in to comment.