Skip to content

Commit

Permalink
[Feature:Autograding] Add Erlang image (#53)
Browse files Browse the repository at this point in the history
### Please check if the PR fulfills these requirements:

* [X] Tests for the changes have been added/updated (if possible)
* [X] Documentation has been updated/added if relevant

### What is the current behavior?
<!-- List issue if it fixes/closes/implements one using the "Fixes
#<number>" or "Closes #<number>" syntax -->
N/A

### What is the new behavior?
Can now run Erlang files

### Other information?
<!-- Is this a breaking change? -->
<!-- How did you test -->
I tested it using the code below
```erl
-module(concurrency).
-export([start/0, process/0]).

start() ->
    Pid = spawn(concurrency, process, []),
    Pid ! {self(), "Hello"},
    receive
        {Pid, Msg} -> io:format("Received message: ~p~n", [Msg])
    end.

process() ->
    receive
        {Sender, Msg} ->
            Sender ! {self(), Msg}
    end.
```

![image](https://github.com/user-attachments/assets/8ee78e7a-5a29-4ecf-8669-348242d45a0d)
  • Loading branch information
ION606 authored Oct 11, 2024
1 parent 2f15550 commit b22a0ef
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
39 changes: 39 additions & 0 deletions dockerfiles/erlang/26/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Use the base image
FROM ubuntu:22.04

WORKDIR /usr/src/app
ENV LANG=C.UTF-8
ENV DEBIAN_FRONTEND=noninteractive
ENV KERL_BASE_DIR=/usr/local/kerl

# Install dependencies for Erlang and the build process
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
build-essential \
libncurses5-dev libsctp1 \
ca-certificates wget curl git \
autoconf m4 libssl-dev libwxgtk3.0-gtk3-dev libgl1-mesa-dev \
libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop \
locales; \
rm -rf /var/lib/apt/lists/*

# Install kerl to manage Erlang builds
RUN curl -O https://raw.githubusercontent.com/kerl/kerl/master/kerl && \
chmod +x kerl && \
mv kerl /usr/local/bin/kerl

# Update kerl releases and build Erlang 26.0
RUN kerl update releases
RUN MAKEFLAGS=-j6 kerl build 26.0 26.0_build
RUN kerl install 26.0_build /usr/local/erlang/26.0

# Cleanup the build files
RUN rm -rf /usr/local/kerl/builds/26.0_build

# Activate the Erlang environment by default
RUN echo ". /usr/local/erlang/26.0/activate" >> /root/.bashrc && \
echo ". /usr/local/erlang/26.0/activate" >> /etc/profile

# Default command
CMD ["/bin/bash"]
3 changes: 3 additions & 0 deletions dockerfiles/erlang/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"pushLatest": false
}

0 comments on commit b22a0ef

Please sign in to comment.