├── VERSION ├── Dockerfile ├── LICENSE ├── Makefile └── README.md /VERSION: -------------------------------------------------------------------------------- 1 | 1.7.4 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM bitwalker/alpine-erlang:21.1.1 2 | 3 | LABEL maintainer="Paul Schoenfelder " 4 | 5 | # Important! Update this no-op ENV variable when this Dockerfile 6 | # is updated with the current date. It will force refresh of all 7 | # of the base images and things like `apt-get update` won't be using 8 | # old cached versions when the Dockerfile is built. 9 | ENV REFRESHED_AT=2018-11-03 \ 10 | ELIXIR_VERSION=v1.7.4 11 | 12 | WORKDIR /tmp/elixir-build 13 | 14 | RUN \ 15 | apk --no-cache --update upgrade && \ 16 | apk add --no-cache --update --virtual .elixir-build \ 17 | make && \ 18 | apk add --no-cache --update \ 19 | git && \ 20 | git clone https://github.com/elixir-lang/elixir --depth 1 --branch $ELIXIR_VERSION && \ 21 | cd elixir && \ 22 | make && make install && \ 23 | mix local.hex --force && \ 24 | mix local.rebar --force && \ 25 | cd $HOME && \ 26 | rm -rf /tmp/elixir-build && \ 27 | apk del --no-cache .elixir-build 28 | 29 | WORKDIR ${HOME} 30 | 31 | CMD ["/bin/sh"] 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-2018 Paul Schoenfelder 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: help 2 | 3 | VERSION ?= `cat VERSION` 4 | MAJ_VERSION := $(shell echo $(VERSION) | sed 's/\([0-9][0-9]*\)\.\([0-9][0-9]*\)\(\.[0-9][0-9]*\)*/\1/') 5 | MIN_VERSION := $(shell echo $(VERSION) | sed 's/\([0-9][0-9]*\)\.\([0-9][0-9]*\)\(\.[0-9][0-9]*\)*/\1.\2/') 6 | IMAGE_NAME ?= bitwalker/alpine-elixir 7 | 8 | help: 9 | @echo "$(IMAGE_NAME):$(VERSION)" 10 | @perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' 11 | 12 | test: ## Test the Docker image 13 | docker run --rm -it $(IMAGE_NAME):$(VERSION) erl -version 14 | 15 | shell: ## Run an Elixir shell in the image 16 | docker run --rm -it $(IMAGE_NAME):$(VERSION) iex 17 | 18 | sh: ## Boot to a shell prompt 19 | docker run --rm -it $(IMAGE_NAME):$(VERSION) /bin/sh 20 | 21 | build: ## Build the Docker image 22 | docker build --force-rm -t $(IMAGE_NAME):$(VERSION) -t $(IMAGE_NAME):$(MIN_VERSION) -t $(IMAGE_NAME):$(MAJ_VERSION) -t $(IMAGE_NAME):latest . 23 | 24 | clean: ## Clean up generated images 25 | @docker rmi --force $(IMAGE_NAME):$(VERSION) $(IMAGE_NAME):$(MIN_VERSION) $(IMAGE_NAME):$(MAJ_VERSION) $(IMAGE_NAME):latest 26 | 27 | rebuild: clean build ## Rebuild the Docker image 28 | 29 | release: build ## Rebuild and release the Docker image to Docker Hub 30 | docker push $(IMAGE_NAME):$(VERSION) 31 | docker push $(IMAGE_NAME):latest 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Elixir on Alpine Linux 2 | 3 | This Dockerfile provides a full installation of Erlang and Elixir on Alpine, intended for running releases, 4 | so it has no build tools installed. The Erlang installation is provided so one can avoid cross-compiling 5 | releases. The caveat of course is if one has NIFs which require a native compilation toolchain, but that is 6 | left as an exercise for the reader. 7 | 8 | ## Usage 9 | 10 | NOTE: This image sets up a `default` user, with home set to `/opt/app` and owned by that user. The working directory 11 | is also set to `$HOME`. It is highly recommended that you add a `USER default` instruction to the end of your 12 | Dockerfile so that your app runs in a non-elevated context. 13 | 14 | To boot straight to a prompt in the image: 15 | 16 | ``` 17 | $ docker run --rm -it --user=root bitwalker/alpine-elixir iex 18 | Erlang/OTP 21 [erts-10.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] 19 | 20 | Interactive Elixir (1.7.4) - press Ctrl+C to exit (type h() ENTER for help) 21 | iex(1)> 22 | ``` 23 | 24 | Extending for your own application: 25 | 26 | ```dockerfile 27 | FROM bitwalker/alpine-elixir:1.7.4 28 | 29 | # Set exposed ports 30 | EXPOSE 5000 31 | ENV PORT=5000 32 | 33 | ENV MIX_ENV=prod 34 | 35 | COPY yourapp.tar.gz ./ 36 | RUN tar -xzvf yourapp.tar.gz 37 | 38 | USER default 39 | 40 | CMD ./bin/yourapp foreground 41 | ``` 42 | 43 | ## License 44 | 45 | MIT 46 | --------------------------------------------------------------------------------