We should investigate what the missing steps are for supporting deploying Prisma servers as a Docker app to Zeit now
@marktani
I have this working as following:
Simply copy across a yml file with the prisma config in the dockerfile
:
FROM prismagraphql/prisma:1.12-alpha
ARG PRISMA_CONFIG_PATH
ENV PRISMA_CONFIG_PATH prisma.yml
COPY config.yml prisma.yml
EXPOSE 4466
The local file config.yml
contains the following:
managementApiSecret: PRISMA_MANAGEMENT_API_SECRET
port: 4466
databases:
default:
connector: mysql
host: SQL_HOST
port: SQL_PORT
user: SQL_USER
password: SQL_PASSWORD
migrations: true
active: true
The main issue preventing this from being used in production is that currently Now does not seem to be passing any environment variables to the docker build.
https://github.com/zeit/now-cli/issues/522
https://github.com/zeit/now-cli/issues/1446
Once they have fixed that you could then pass SQL_PASSWORD
and PRISMA_MANAGEMENT_API_SECRET
as environment vars.
e.g:
RUN sed -i s/SQL_PASSWORD/$SQL_PASSWORD/g prisma.yml
Ideally, we would want to pass the entire Prisma configuration as a single environment var, but Now does not support base64. See https://github.com/zeit/now-cli/issues/749.
@marktani @develomark Looks like this feature has landed in Now :tada:: https://zeit.co/blog/build-env
This is great news. Zeit seems to be moving quite fast now. I'll update the script/instructions and update here.
Example of how to deploy to Now here: https://github.com/develomark/prisma-now
This is great - however I just tried to run this, and the build failed because -
> â–² The built image size (117.5M) exceeds the 100MiB limit
> Error! Build failed
Is this just a limit of the free plan?
Zeit seems to have a hard limit of 100MiB on image size, regardless of plan https://github.com/zeit/now-cli/issues/1523
Ah, I realise I was using v2, instead of v1 the guide must use by default?
Now I have changed the features -> docker flag to v1, It builds fine.
Is there any way to reduce the base Prisma image size, so we can use v2?
Temporary solution seems to use the Docker v1 for Zeit.
In now.json
add:
"features": {
"cloud": "v1"
}
Have created a PR to update the docs, reflecting the above - #2965
Maybe this https://github.com/zeit/now-examples/blob/master/java-vertx-jlink/Dockerfile could be helpful to optimize the resulting image size
Am I correct in thinking it is this section which is responsible for creating the Docker image?
It would be great to get the compressed size under 100MB so it can be deployed on now in V2.
Thanks for the great example @develomark!
We are working to bring the docker image below 100 mb, but until then deploying to Now v1 as detailed above is the recommended workaround.
@sorenbs @marktani Apart from image size, do you think it would be possible to have horizontal scaling in Now?
It seems to be a very good platform for that but I'm not sure if Prisma is compatible since, if I'm not wrong, it needs to redirect management requests to only 1 specific server. I don't think that's currently possible in Now 🤔
@frandiox - that's a great question!
Now is certainly a great hosting platform. We are going to simplify Prisma cluster management to enable easy setup on a platform like Now. Currently you need to configure routing as you describe as well as operate a RabbitMQ instance. We want to remove both requirements. We don't have a timeline for when this will happen.
@sorenbs There might be a workaround to scale Prisma in Now although I haven't tried it myself yet.
It should be possible to have 1 instance of a Prisma server for management API which is only used by the developer or the CI in order to deploy schema changes. Secondly, an auto-scaled instance of Prisma server without management API used by actual apps. RabbitMQ would still be necessary, though (related #2867). Do you think that would work?
Interesting.
I currently have a setup where I was under the impression that I had autoscaling on my Prisma instances. Did I overlook something? My setup is this:
Everything works, albeit with fairly high request times reported by Apollo Engine, P95 is around 1.3 seconds, pending further investigation - but maybe I overlooked something here that might be a factor?
@frandiox - that would work, but it is quite a bit more complicated than we would like it to be :-)
@sorenbs - any reason using autoscaling Now v1 won't work?
@jhalborg I have the exact same setup - and am also interested about if Now autoscaling works...
This issue has details on what you'd need to do:
https://github.com/prisma/prisma/issues/2850
On Thu, 1 Nov 2018, 01:54 Travis Reynolds <[email protected] wrote:
@jhalborg https://github.com/jhalborg I have the exact same setup - and
am also interested about if Now autoscaling works...—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/prisma/prisma/issues/2501#issuecomment-434781653, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ACll3ykUb06M9WPlz4Kmc7Pr-iLWdWMCks5uqePlgaJpZM4UKdQs
.
So to be clear, unless we want to set up a crazy Kubernetes + RabbitMQ setup or pay for managed hosting on Prisma Cloud, we can't scale horizontally as of now?
I gotta say, this is a huge bummer. I'm going to move my Prisma server to a vertically scaled EC2 instance for now, and hope that this improves within the next couple of months before I really need it.
🤞that this gets some priority 😄
@jhalborg
@sorenbs There might be a workaround to scale Prisma in Now although I haven't tried it myself yet.
It should be possible to have 1 instance of a Prisma server for management API which is only used by the developer or the CI in order to deploy schema changes. Secondly, an auto-scaled instance of Prisma server without management API used by actual apps. RabbitMQ would still be necessary, though (related #2867). Do you think that would work?
@frandiox - that would work, but it is quite a bit more complicated than we would like it to be :-)
Why don't you try that?
@frandiox - Haven't ever worked with RabbitMQ, and I fear I don't have time to look into it before our product launch. 😥
Most helpful comment
Example of how to deploy to Now here: https://github.com/develomark/prisma-now