Skip to content

Instantly share code, notes, and snippets.

@JorgenEvens
Created November 29, 2022 15:55
Show Gist options
  • Save JorgenEvens/565f0c6d3591d249bcc5bf9cbbc8f785 to your computer and use it in GitHub Desktop.
Save JorgenEvens/565f0c6d3591d249bcc5bf9cbbc8f785 to your computer and use it in GitHub Desktop.
Dockerizing our Heroku apps
ARG STACK_VERSION=20
FROM gliderlabs/herokuish:latest-${STACK_VERSION} AS build
COPY . /tmp/app
ARG NPM_TOKEN
ENV NODE_ENV=production
RUN (cat /tmp/app/app.json || echo '{}') | jq -r '.buildpacks[].url' > /tmp/app/.buildpacks && \
(test -s /tmp/app/.buildpacks || rm /tmp/app/.buildpacks)
RUN /build && \
rm -Rf /tmp/* && \
rm -Rf /app/.npmrc
RUN herokuish slug generate && \
herokuish slug export > /app.tar.gz
FROM gliderlabs/herokuish:latest-${STACK_VERSION}
ENV PORT 3000
ENV NODE_ENV=production
COPY --from=0 /etc /etc
RUN --mount=type=bind,from=build,source=/app.tar.gz,target=/app.tar.gz \
herokuish slug import < /app.tar.gz
ENTRYPOINT [ "/start" ]
CMD [ "web" ]
APP_NAME?=some-app
APP_NAMESPACE?=default
IMAGE_NAME?="ambassify/$(APP_NAME)"
export DOCKER_BUILDKIT = 1
up: build
docker run -t -i \
-e PORT=3000 \
-p 3000:3000/tcp \
$(IMAGE_NAME)
pull:
docker pull gliderlabs/herokuish
build: pull
docker build --build-arg NPM_TOKEN -t $(IMAGE_NAME) .
debug: build
docker run -t -i --entrypoint /bin/bash $(IMAGE_NAME)
publish: build
docker tag $(IMAGE_NAME) ghcr.io/$(IMAGE_NAME)
docker push ghcr.io/$(IMAGE_NAME)
deploy: publish
kubectl rollout restart deployment $(APP_NAME) -n $(APP_NAMESPACE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment