yesod devel + stack + docker compose

188 views
Skip to first unread message

Matthew Griffith

unread,
Apr 6, 2016, 11:52:51 PM4/6/16
to Yesod Web Framework
Hello!

I have a yesod site that sits behind nginx and connects to a postgres database.  I'm currently trying to use docker-compose to simplify deployment and I was hoping to get some advice on how to get it working.


The docker-compose.yml that I'm using, which is meant for local development, is pasted below. I have a separate one that is used for deployment, but I figure if I can get this working, the other will follow.


db:
  restart: always
  image: postgres:latest
  environment:
    POSTGRES_PASSWORD: postgres
    POSTGRES_USER: postgres
  expose:
    - "5432"

nginx:
  restart: always
  build: ./nginx/
  ports:
    - "80:80"
  volumes:
    - /www/static
  volumes_from:
    - server
  links:
    - server:server

server:
  restart: always
  command: stack exec yesod devel
  build: ./web/
  expose:
    - "3000"
  links:
    - db
  volumes:
    - ./web:/usr/src/app


The Dockerfile for the Yesod app is 

FROM fpco/stack-build
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN stack build


Currently, when I run this by spinning up a machine through docker-machine and running
docker-compose build
docker-compose up -d

The build succeeds as far as I can tell, but runnning the composition fails with
You are not the owner of '/usr/src/app/.stack-work/'. Aborting to protect file permissions.
Retry with '--allow-different-user' to disable this precaution.

After adding --allow-different-user  (which I'd rather not use if it isn't necessary)

It fails with
Executable named yesod not found on path: ["/usr/src/app/.stack-work/install/x86_64-linux/lts-5.11/7.10.3/bin","/root/.stack/snapshots/x86_64-linux/lts-5.11/7.10.3/bin","/opt/host/bin","/opt/stackage/lts-5/extra/bin","/opt/stackage/lts-5/ghc/bin","/opt/stackage/lts-5/tools/bin","/usr/local/sbin","/usr/local/bin","/usr/sbin","/usr/bin","/sbin","/bin"]


As a side note, I know that stack has the ability to create docker images (which is fantastic), though I don't know how to make that capability work with docker-compose.  I'm used to just throwing a Dockerfile in a directory and referencing it in the docker-compose.yml.


I feel like I'm missing something basic, can anyone point me in the right direction?

Much appreciated!
-Matt


Michael Snoyman

unread,
Apr 7, 2016, 3:07:59 AM4/7/16
to Yesod Web Framework

The Stack image you're using doesn't have the yesod executable. You could build it by running stack build yesod-bin, but most likely you want to create your own build image that has all your dependencies precompiled.


--
You received this message because you are subscribed to the Google Groups "Yesod Web Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yesodweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matthew Griffith

unread,
Apr 7, 2016, 11:21:28 AM4/7/16
to Yesod Web Framework, mic...@snoyman.com
Thank you, that was the nudge I needed.
Reply all
Reply to author
Forward
0 new messages