Skip to content
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

Provide Alpine Docker image #867

Closed
mcarans opened this issue Apr 25, 2017 · 11 comments
Closed

Provide Alpine Docker image #867

mcarans opened this issue Apr 25, 2017 · 11 comments

Comments

@mcarans
Copy link

mcarans commented Apr 25, 2017

It would be good to have an Alpine Docker image. I have created one here:
https://hub.docker.com/r/mcarans/alpine-haskell-postgrest/ which uses the last version of Postgrest that worked with Alpine 3.4.
(Git commit hash: 726b2b9)

It can be used in docker-compose.yml like this:
rest:
image: mcarans/alpine-haskell-postgrest
ports:
- "3000:3000"
environment:
- DB_URL=${DB_URL}
- DB_USER=${DB_USER}
command: ["sh", "/root/runpostgrest.sh"]
logging:
driver: "json-file"
options:
max-size: "100k"
max-file: "1"

@begriffs
Copy link
Member

Thanks for putting that together. Can you try making some API requests to it and leaving it running for a while? Last time we experimented with Alpine we ran into a GHC memory leak that appears to be related to that platform.

@ruslantalpa
Copy link
Contributor

@mcarans it's not about leaving it for a while, you need to send a lot of requests to PostgREST to use up some memory so that GC has something to clean up. You need to generate like upwords of 1M requests in a short time frame (5-10min). Watch the memory used at the beginning, see it grow during the test. If it the end, the memory usage goes down to the initial level, you are fine but i think it will stay up (this is what i saw when i did this test in the past, didn't feel like tracking this down since alpine is not an officially supported platform of GHC, and the bug seems to be a very low level)

@mcarans
Copy link
Author

mcarans commented Apr 27, 2017

Ok maybe you can make an Alpine Postgrest image available (or point to mine as an unofficial one) with a warning that millions of requests per minute has been known to cause a memory leak (as Alpine is not a supported platform for GHC) so people can choose to use it or not given the warning.

So far Postgrest on Alpine has been up since 20 April but there are few requests going to it.

@ruslantalpa
Copy link
Contributor

the problem does not appear ONLY when you have a big rps number. The problem is that used memory does not get cleaned up at any volume. whatever your load, eventually your server is going to run out of memory and crash. The 1m number was just a way for you to flash out the bug in a short timespan (5min). Unless this is fixed i would not suggest to anyone to use alpine with postgrest in any setting. This is a fundamental bug that can have weird manifestations so i would not want ppl submitting bugs like "postgrest crashed/uses a lot of memory" and finding out 2 days into debuging that he is using an alpine image

@mcarans
Copy link
Author

mcarans commented Apr 27, 2017

Ok fair enough. I will let you know how things go with leaving my Postgrest running. Do you recall what Alpine and GHC versions you tested before? The image I created is for Alpine 3.4, GHC 7.10.

GHC is in Alpine testing now: alpinelinux/aports#205

@just1689
Copy link
Contributor

just1689 commented Aug 9, 2017

@mcarans Any news?

@mcarans
Copy link
Author

mcarans commented Aug 9, 2017

It seems to be stable for me - no issues - but then it is not receiving that many requests, certainly not the millions per minute necessary to surface the bug.

@danilobuerger
Copy link

@mcarans Could you please provide an up to date Dockerfile thats using ghc from testing?

@mcarans
Copy link
Author

mcarans commented Aug 15, 2017

FROM unocha/alpine-base:latest

MAINTAINER XXX <XXX@XXX.com>

RUN echo "https://s3-us-west-2.amazonaws.com/alpine-ghc/7.10" >> /etc/apk/repositories && \
    curl -so /root/runpostgrest.sh \
        https://raw.githubusercontent.com/OCHA-DAP/alpine-haskell-postgrest/master/runpostgrest.sh && \
    curl -so /etc/apk/keys/mitch.tishmack@gmail.com-55881c97.rsa.pub \
        https://raw.githubusercontent.com/mitchty/alpine-ghc/master/mitch.tishmack%40gmail.com-55881c97.rsa.pub && \
    apk add --no-cache --update build-base git xz postgresql-dev ghc stack && \
    git clone https://github.com/begriffs/postgrest.git --single-branch && \
    cd postgrest && \
    git checkout 726b2b9d18a3b8217d83c514122560fd5f71af95 && \
    stack build --copy-bins --local-bin-path /usr/local/bin && \
    stack clean --full && \
    cd .. && \
    rm -rf postgrest && \
    apk del build-base git xz postgresql-dev ghc stack && \
    apk add --no-cache libpq gmp && \
    rm -r /root/.stack && \
    rm -rf /var/lib/apk/*

CMD ["postgrest", "$DB_URL", "-a", "XXX"]

Replace XXX above appropriately. Note that I wanted to use one of our org's base images and so was restricted to a non-current version of Alpine (3.4), hence the checkout of a specific commit, the last to support the Alpine version.

Also it is here: https://hub.docker.com/r/mcarans/alpine-haskell-postgrest/

@ruslantalpa
Copy link
Contributor

we now have an automated release script. you could add a PR to build the alpine specific binary and docker.

@ruslantalpa
Copy link
Contributor

ruslantalpa commented Sep 19, 2017

@mcarans a PR would be welcomed.

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

No branches or pull requests

5 participants