Skip to content

Commit 12a2171

Browse files
committed
Add dockerfile to prepare Flyio deploy and update 2023 info
1 parent 1ae69c4 commit 12a2171

File tree

15 files changed

+210
-13700
lines changed

15 files changed

+210
-13700
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fly.toml
2+
Dockerfile
3+
.dockerignore
4+
node_modules
5+
.git

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ lerna-debug.log*
3333
!.vscode/launch.json
3434
!.vscode/extensions.json
3535

36-
.env
36+
.env
37+
.env.*

Dockerfile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# PRODUCTION DOCKERFILE
2+
# ---------------------
3+
# This Dockerfile allows to build a Docker image of the NestJS application
4+
# and based on a NodeJS 16 image. The multi-stage mechanism allows to build
5+
# the application in a "builder" stage and then create a lightweight production
6+
# image containing the required dependencies and the JS build files.
7+
#
8+
# Dockerfile best practices
9+
# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
10+
# Dockerized NodeJS best practices
11+
# https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md
12+
# https://www.bretfisher.com/node-docker-good-defaults/
13+
# http://goldbergyoni.com/checklist-best-practice-of-node-js-in-production/
14+
15+
16+
# Credit: https://github.com/Saluki/nestjs-template/blob/master/Dockerfile
17+
18+
FROM node:16-alpine as builder
19+
20+
ENV NODE_ENV build
21+
22+
RUN addgroup -S app && adduser -S app -G node
23+
RUN chown -R app:node /home/node
24+
25+
# Add git to be able to clone the "RevolutionUC-emails" repo
26+
RUN apk add --no-cache git
27+
28+
USER root
29+
WORKDIR /home/node
30+
31+
COPY --chown=node package.json yarn.lock ./
32+
RUN yarn install --frozen-lockfile
33+
34+
COPY --chown=node . .
35+
36+
# Fly.io build secrets: https://fly.io/docs/reference/build-secrets/
37+
RUN yarn run build \
38+
&& yarn install --production
39+
40+
# ---
41+
42+
LABEL fly_launch_runtime="nodejs"
43+
44+
FROM node:16-alpine
45+
46+
ENV NODE_ENV production
47+
48+
USER node
49+
WORKDIR /home/node
50+
51+
COPY --from=builder /home/node/package*.json /home/node/
52+
COPY --from=builder /home/node/node_modules/ /home/node/node_modules/
53+
COPY --from=builder /home/node/dist/ /home/node/dist/
54+
55+
EXPOSE 8080
56+
57+
CMD ["node", "dist/main.js"]

fly.toml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# fly.toml file generated for revuc-api on 2023-01-22T12:55:05-05:00
2+
3+
app = "revuc-api"
4+
kill_signal = "SIGINT"
5+
kill_timeout = 5
6+
processes = []
7+
8+
[env]
9+
CURRENT_INFO_EMAIL = "infoEmail4"
10+
PORT = "8080"
11+
12+
[experimental]
13+
auto_rollback = true
14+
15+
[[services]]
16+
http_checks = []
17+
internal_port = 8080
18+
processes = ["app"]
19+
protocol = "tcp"
20+
script_checks = []
21+
[services.concurrency]
22+
hard_limit = 25
23+
soft_limit = 20
24+
type = "connections"
25+
26+
[[services.ports]]
27+
force_https = true
28+
handlers = ["http"]
29+
port = 80
30+
31+
[[services.ports]]
32+
handlers = ["tls", "http"]
33+
port = 443
34+
35+
[[services.tcp_checks]]
36+
grace_period = "1s"
37+
interval = "15s"
38+
restart_limit = 0
39+
timeout = "2s"

0 commit comments

Comments
 (0)