Skip to content

Instantly share code, notes, and snippets.

@unscriptable
Last active February 12, 2019 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unscriptable/6c8f956ce9248deac88598dc8e20ccb8 to your computer and use it in GitHub Desktop.
Save unscriptable/6c8f956ce9248deac88598dc8e20ccb8 to your computer and use it in GitHub Desktop.
Makefile to compile Elm in a container
# NOTE will not work with make -v 3.81 or lower
SHELL = /bin/bash
.RECIPEPREFIX = >
# run docker as current user so we don't get elm-stuff permissions problems
UID ?= $(shell id -u):$(shell id -g)
GIT_REPO_ROOT ?= $(PWD)
PROJECT_ROOT := $(GIT_REPO_ROOT)
# My app
APP_NAME := myapp
APP_ROOT := $(PROJECT_ROOT)/$(APP_NAME)
APP_MAIN := src/Main.elm
APP_OUTPUT := $(APP_NAME)/elm-output
# Build the app in the codesimple docker container
.PHONY: myapp
myapp:
> docker run --rm -it \
> -u $(UID) \
> -v $(APP_ROOT):/$(APP_NAME) -w /$(APP_NAME) \
> -v $(PROJECT_ROOT)/elm-stuff:/tmp -e "HOME=/tmp" \
> codesimple/elm:0.19 \
> make $(APP_MAIN) --output=/$(APP_OUTPUT)/myapp.html
# Clean
# Clean built files
.PHONY: clean
clean:
> rm -rf $(APP_OUTPUT)
# Clean all cached dependencies and built files
.PHONY: clean-all
clean-all:
> rm -rf $(PROJECT_ROOT)/$(APP_OUTPUT)
> rm -rf $(PROJECT_ROOT)/elm-stuff
> rm -rf $(APP_ROOT)/elm-stuff
@unscriptable
Copy link
Author

Note: I've noticed that I need to wait 1-2 seconds before my changes on my local file system (macOS 10.14.3) are available to the docker container (Engine: 18.09.1, Compose: 1.23.2, Machine: 0.16.1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment