generated from remix-run/indie-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
101 lines (74 loc) · 2.52 KB
/
Dockerfile
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# base node image
FROM node:20-bullseye-slim as base
# set for base and all layer that inherit from it
ENV NODE_ENV production
# pass down env variables
ARG SESSION_SECRET
ARG AGENCY_NAME
ARG MAPBOX_ACCESS_TOKEN
ARG GTFS_URL
ARG ADMIN_EMAIL
ARG ADMIN_PASSWORD
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
ARG S3_BUCKET
ARG DATABASE_URL
ENV DATABASE_URL=${DATABASE_URL}
ENV SESSION_SECRET=${SESSION_SECRET}
ENV AGENCY_NAME=${AGENCY_NAME}
ENV MAPBOX_ACCESS_TOKEN=${MAPBOX_ACCESS_TOKEN}
ENV GTFS_URL=${GTFS_URL}
ENV ADMIN_EMAIL=${ADMIN_EMAIL}
ENV ADMIN_PASSWORD=${ADMIN_PASSWORD}
ENV REPLICA_URL=s3://${S3_BUCKET}/data.db
ENV S3_BUCKET=${S3_BUCKET}
ENV AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
ENV AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
ADD https://github.com/benbjohnson/litestream/releases/download/v0.3.8/litestream-v0.3.8-linux-amd64-static.tar.gz /tmp/litestream.tar.gz
RUN tar -C /usr/local/bin -xzf /tmp/litestream.tar.gz
# Install openssl for Prisma
RUN apt-get update && apt-get install -y openssl sqlite3
# Install all node_modules, including dev dependencies
FROM base as deps
WORKDIR /remix
ADD package.json .npmrc ./
RUN npm install --include=dev
# Setup production node_modules
FROM base as production-deps
WORKDIR /remix
COPY --from=deps /remix/node_modules /remix/node_modules
ADD package.json .npmrc ./
RUN npm prune --omit=dev
# Build the app
FROM base as build
WORKDIR /remix
COPY --from=deps /remix/node_modules /remix/node_modules
ADD . .
RUN npm run build
ADD drizzle .
RUN npm run generate
RUN npm run db:push
ENV PORT="8080"
ENV NODE_ENV="production"
# Copy Litestream configuration file & startup script.
COPY etc/litestream.yml /etc/litestream.yml
COPY scripts/run.sh /scripts/run.sh
CMD [ "/scripts/run.sh" ]
# RUN npm run gtfs
# RUN npm run predeploy
# Finally, build the production image with minimal footprint
FROM base
# add shortcut for connecting to database CLI
RUN echo "#!/bin/sh\nset -x\nsqlite3 \$DATABASE_URL" > /usr/local/bin/database-cli && chmod +x /usr/local/bin/database-cli
WORKDIR /remix
COPY --from=production-deps /remix/node_modules /remix/node_modules
COPY etc/litestream.yml /etc/litestream.yml
COPY scripts/run.sh /scripts/run.sh
COPY --from=build /remix/build /remix/build
COPY --from=build /remix/public /remix/public
COPY --from=build /remix/package.json /remix/package.json
COPY --from=build /remix/start.sh /remix/start.sh
COPY --from=build /remix/html /remix/html
COPY --from=build /remix/geojson /remix/geojson
COPY --from=build /remix/drizzle /remix/drizzle
ENTRYPOINT [ "./start.sh" ]