How do I use Haskell Stack with Docker Compose?

I am trying to use docker compose to bundle some haskell services for local development. Most of the time I've been messing around stack ghci

, testing unit tests, etc., but I also need to be able to run code that affects the dependency. Docker compose is great for this: I can run dependencies (databases, other services, etc.) and bundle everything together.

The stack has docker support. It can create a docker container with docker: enable: true

and can also create an executable image with stack image container

.

How do I use the dock functionality on the stack internally docker-compose.yml

?

version: "3"

services:

  my-service:

    # how can I use `stack image container` here? Is it possible?
    build: '.'

    links:
    - other-service

    env_file:
    - test.env

  other-service:
    image: other-service-image

      

Do I have to make my own Dockerfile, or is there a way to use the functionality stack image container

?

Follow-up questions: is there a way to run stack ghci

with all settings (env, links, etc.) from a docker compose file?

+3


source to share


1 answer


This only answers your question (ghci stack in docker). Yes, it is possible.

Depending on what your service / container is named (you can define this with docker ps

):



If your container is already running (via docker-compose up

/ docker run

):

docker exec -it directoryName_my-service_1 /bin/stack ghci

+1


source







All Articles