-
Notifications
You must be signed in to change notification settings - Fork 9
/
Dockerfile.production
61 lines (53 loc) · 2.26 KB
/
Dockerfile.production
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
ARG STACK_VERSION=20
ARG NODE_ENV=production
ARG RAILS_ENV=production
# ------------
# add application code to herokuish container
# build application (and install correct buildpacks from app.json along with it)
# generate slug as app.tar.gz
# ------------
# We need to specify linux/amd64 here because herokuish (and the heroku images further back) are not multi-platform
# So if we want to run this on a different architecture (eg silicon macs (linux/amd64/v8) and linux/arm64),
# we need to specify it here to make sure it gets the right platform from the herokuish image
# we also need to specify the platform when we build the image too (if running on a non arm64 machine)
# https://github.com/heroku/heroku-buildpack-nodejs/issues/1268
# https://github.com/heroku/heroku-buildpack-ruby/issues/1457
# https://github.com/heroku/base-images/issues/194
FROM --platform=linux/amd64 gliderlabs/herokuish:latest-${STACK_VERSION} AS build
COPY . /tmp/app
ARG NODE_ENV
ARG RAILS_ENV
ENV NODE_ENV=${NODE_ENV}
ENV RAILS_ENV=${RAILS_ENV}
# tmp NODE_OPTIONS for now
ENV NODE_OPTIONS=--openssl-legacy-provider
RUN (cat /tmp/app/app.json || echo '{}') | jq -r '.buildpacks[].url' > /tmp/app/.buildpacks && \
(test -s /tmp/app/.buildpacks || rm /tmp/app/.buildpacks)
# RUN (cat /tmp/app/app.json || echo '{}') | jq -r '.environments.test.buildpacks[].url' > /tmp/app/.buildpacks && \
# (test -s /tmp/app/.buildpacks || rm /tmp/app/.buildpacks)
RUN while IFS= read -r line; do herokuish buildpack install "$line"; done < /tmp/app/.buildpacks
RUN /build && \
rm -Rf /tmp/*
RUN herokuish slug generate && \
herokuish slug export > /app.tar.gz
# ------------
# open herokuish container and import built slug from previous stage skipping build steps
# run the application
# ------------
FROM gliderlabs/herokuish:latest-${STACK_VERSION}
RUN apt-get update --error-on=any
# install postgres client
RUN apt-get install -y postgresql-client
ENV PORT 3000
ARG NODE_ENV
ARG RAILS_ENV
ENV NODE_ENV=${NODE_ENV}
ENV RAILS_ENV=${RAILS_ENV}
# tmp NODE_OPTIONS for now
ENV NODE_OPTIONS=--openssl-legacy-provider
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" ]
# CMD ["tail", "-f", "/dev/null"]