Postgraphile: Versioned docker images

Created on 10 Dec 2018  路  15Comments  路  Source: graphile/postgraphile

I'm submitting a ...

  • [ ] bug report
  • [ ] feature request
  • [x] question

I've been testing PostGraphile for a few weeks now in an application that is still in prototype stage. As this is turning out to be very promising (great job team!) I started to wonder about your plans to also version the published docker images. Thanks!

馃拝 enhancement 馃檹 help-wanted

Most helpful comment

Docker Hub has to clear a few builds first; but postgraphile:4 should be automatically updated in the next few hours.

Screenshot 2019-06-24 17 09 26

All 15 comments

For anyone following, this was discussed a little on Discord:

https://discordapp.com/channels/489127045289476126/489127045826215962/521789827046309907

Help from people more experienced on DockerHub than I would be very welcome.

Ugh, that's a mess - the latest tag can be useful for development, but anyone trying to use it in business etc will want actual tag names. The Dockerfile uses node:alpine, so versions should probably be something along the lines of v4.4.0-alpine - the base image name should be the same as the npm version / Github release tag (so including -alpha / -beta etc).

If using the latest tag at all, then that should always be the same as the latest actual build - even if it would actually break things (there's a reason so many people dislike it) ;-)

If someone wants to go back to previous builds since adding the Dockerfile and create/tag/push those then that would be nice, but not required.

If there are any non-release builds made, then they should only ever update the latest tag - and not pollute the namespace with needless build names - there's nothing wrong with making tags for when the package.json version has been updated and it's not an actual release though (just match that version number etc).

@Rycochet would you be interested in guiding me through configuring all this (maybe via screen sharing)? I don't use Docker much, and Docker Hub even less, so I'm not aware of the conventions or how to set them up automatically with minimal effort. Someone else set up the existing Docker Hub builds for me.

I've got all of our builds setup via automatic CI (Jenkins / Jenkinsfile) jobs - the actual commands needed for it are basically docker build, docker tag ... ..., docker push ... - I'm somewhat snowed under in general, but will see if I can dedicate some time to it at work :-)

That鈥檇 be fantastic @rycochet; I know Docker hub have automated builds but currently it just installs from npm so Docker always lags slightly. Would be nice to have it run the actual build without enlarging the image too much.

Would be nice to have it run the actual build without enlarging the image too much.

Docker's multi-stage builds might be able to help with that 馃槉

I am interested in contributing for this. Going over the existing Dockerfile and this discussion, here's my understanding:

  1. The Dockerfile currently installs the latest published postgraphile version from npm. It should ideally be building from source (using the build scripts).
  2. You need CI/CD integration with Docker to publish automatically whenever you do a new release. The releases should be tagged with the right release versions.

Any other requirement I've missed?

I'm actually solving this today; already have the new Dockerfile:

FROM node:12-alpine as builder

WORKDIR /postgraphile/

# Add yarn ASAP because it's the slowest
ADD package.json yarn.lock /postgraphile/
RUN yarn install --frozen-lockfile --production=false

# Now for PostGraphiQL's yarn
ADD postgraphiql/ /postgraphile/postgraphiql/
WORKDIR /postgraphile/postgraphiql/
RUN yarn install --frozen-lockfile --production=false
WORKDIR /postgraphile/

# Copy everything else we need; this stuff will likely change
ADD tsconfig.json tslint.json /postgraphile/
ADD index.js cli.js /postgraphile/
ADD *.md /postgraphile/
ADD src/ /postgraphile/src/
ADD assets/ /postgraphile/assets/
ADD typings/ /postgraphile/typings/
ADD scripts/ /postgraphile/scripts/

# Finally run the build script
RUN ./scripts/build

########################################

FROM node:12-alpine
LABEL description="Instant high-performance GraphQL API for your PostgreSQL database https://graphile.org/postgraphile"

EXPOSE 5000
ENV GRAPHILE_TURBO=1
WORKDIR /postgraphile/
ENTRYPOINT ["./cli.js"]

# Again, install yarn ASAP because it's the slowest
ADD package.json yarn.lock /postgraphile/
RUN yarn install --frozen-lockfile --production=true

ADD *.md /postgraphile/
ADD index.js cli.js /postgraphile/
COPY docker/.postgraphilerc.js /postgraphile/
COPY --from=builder /postgraphile/build/ /postgraphile/build/
COPY --from=builder /postgraphile/build-turbo/ /postgraphile/build-turbo/
COPY --from=builder /postgraphile/sponsors.json /postgraphile/

@purplemana If you're free now, I could do with a hand - swing by our #core-development chat in http://discord.gg/graphile

From now onwards we have versioned Docker images:

  • graphile/postgraphile:4 will give you the latest stable in the "v4.x.x" line (no alphas, betas, rcs); this is the recommended version to use
  • Every new versioned git tag will be available using the exact same tag; e.g. v5.6.7-alpha.8 would become graphile/postgraphile:v5.6.7-alpha.8 (none are currently published)
  • Every new vX.Y.Z git tag (i.e. no alpha/beta/rc) will automatically release graphile/postgraphile:X-Y and graphile/postgraphile:X-Y-Z
  • graphile/postgraphile:latest will give you the latest _stable_ (but beware of major version bumps!)
  • graphile/postgraphile:next will give you the equivalent of what's on master right now (i.e. pre-release/bleeding edge/nightly)

We're currently in a teething period for this, so there may be some bumpiness - if you face any issues, please let me know.

NOTE: this only applies to future releases; we are not back-filling previous releases, so there's not many tags to choose from right now.

graphile/postgraphile:4 will give you the latest stable in the "v4.x.x" line (no alphas, betas, rcs); this is the recommended version to use

@benjie why I have this?

$ docker run --rm graphile/postgraphile:4 --version
4.4.1-alpha.4

Because

this only applies to future releases; we are not back-filling previous releases, so there's not many tags to choose from right now.

We鈥檝e not yet done a new release since setting this up. 4.4.1 should be out soon though. It鈥檒l be almost identical to the version you have, so worry not.

Docker Hub has to clear a few builds first; but postgraphile:4 should be automatically updated in the next few hours.

Screenshot 2019-06-24 17 09 26

Re

graphile/postgraphile:4 will give you the latest stable in the "v4.x.x" line (no alphas, betas, rcs); this is the recommended version to use

I have a similar observation as previously entered back in June ...

I can see newer tags

image

In particular, note the recent v4.4.3 tag.

However, after just pulling graphile/postgraphile:4 as recommended, I'm seeing this afterwards:

$ docker run --rm graphile/postgraphile:4 --version
4.4.1

Also confused by the dots and dashes in the various tags. Thanks for any clarification!

Whoops, I forgot I had to push code to the v4 branch for the Docker to build. I've done that now so hopefully that'll be out in the next hour or two. I've added a reminder:

https://github.com/graphile/graphile-engine/commit/cf0d1e1d3f1cc5ce318e763a71f2a6778ad57e3a

Dots and dashes:

  • X and X-Y are the versions that you should use, they will be updated over time with compatible bug fixes.
  • X-Y-Z for completeness, and may include alpha/beta/etc versions of that specific release in future
  • vX.Y.Z-foo.A or whatever are the explicit git tags which will only ever build once and will not be kept up to date as the project advances. Use these if you need to pin an explicit version... explicitly.
Was this page helpful?
0 / 5 - 0 ratings