Skip to content

Update dockerfile #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 6 additions & 23 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ RUN sudo apt-get install -y build-essential curl libffi-dev libffi7 libgmp-dev l
# We use the official instalation script
RUN sudo curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

# Add ghcup to path
# Env variables:
# - Adds ghcup binaries to path
# - set ghcup instalation script to non-interactive
# - set ghcup instalation script to minimal instalation. That is: just install ghcup and nothing else
ENV PATH=${PATH}:${HOME}/.ghcup/bin
ENV BOOTSTRAP_HASKELL_NONINTERACTIVE=true
ENV BOOTSTRAP_HASKELL_MINIMAL=true

# Set up the environment. This will install the default versions of every tool.
RUN ghcup install ghc
Expand All @@ -22,25 +27,3 @@ RUN ghcup install cabal
# WARNING! Maybe this is not adecuate for your project! use your project wise stack.yaml to change this
RUN stack config set install-ghc --global false
RUN stack config set system-ghc --global true

# If you want to use your own cabal / stack file delete from here to the end of the file
# ********* DELETE FROM HERE **********
# v v v v v v v v v v v v v v v v v v

# Generate the right cabal file. Using cabal init after ghc installation ensures that the right version of base is used
# Otherwise, the template would become deprecated as long as ghcup decides to pick up a different version of ghc.
RUN cabal init \
--license=MIT \
--homepage=https://github.com/gitpod-io/template-haskell \
--author=Gitpod \
--category=Example \
[email protected] \
--package-name=gitpod-template \
--synopsis="See README for more info" \
--libandexe \
--tests \
--test-dir=test \
--overwrite

# similarly, running stack init --force after cabal init, ensures that stack will chose a snapshot compatible with system's ghc
RUN stack init --force
17 changes: 15 additions & 2 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
image:
file: .gitpod.Dockerfile
tasks:
- init:
stack build
- command:
cabal init
--license=MIT
--homepage=https://github.com/gitpod-io/template-haskell
--author=Gitpod
--category=Example
[email protected]
--package-name=gitpod-template
--synopsis="See README for more info"
--libandexe
--tests
--test-dir=test
--overwrite
&& stack init --force
&& stack build
vscode:
extensions:
- haskell.haskell
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,5 @@ Click the above "Open in Gitpod" button to start a new workspace. Once you're re

If you have an existing project and you want to create a gitpod environment for it, you need to follow and take into account these considerations.

- This repo's Dockerfile **completely overwrites** the `cabal` and `stack` files when building the container. This means, that if you simply copy-paste the `.gitpod.Dockerfile`, your `cabal`/`stack` files will disappear. Follow the instructions within `.gitpod.Dockerfile` to change this behaviour.
- For maintainability reasons, the field `tasks.command` in the `.gitpod.yaml` is configured to **completely overwrites** the `.cabal` and `stack.yaml` files. This is likely not what you want, since all dependencies will be lost. Please, configure `task.command` with your build preferences.
- This repo uses `ghcup` to install all the tooling. Alternative installation isn't recommended.
- If you are using `stack` it is **highly** recommended to disallow it from installing `ghc` on its own. Otherwise, you'll encounter problems when integrating with `haskell-language-protocol`. To configure `stack` properly, run the following:
- `stack config set install-ghc --global false`
- `stack config set system-ghc --global true`