Skip to content

Commit 702149a

Browse files
feat: Add cloud integration using Docker and Terraform
1 parent 98803c9 commit 702149a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3135
-0
lines changed

.dockerignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Ignore everything
2+
*
3+
4+
# Allow files and directories
5+
!/.eslintignore
6+
!/.eslintrc.json
7+
!/.prettierrc
8+
9+
!/package.json
10+
!/tsconfig.json
11+
12+
!/development.env
13+
!/production.env
14+
15+
!/public
16+
!/src
17+
!/views
18+
19+
# Ignore unnecessary files inside allowed directories
20+
# This should go after the allowed directories
21+
**/*~
22+
**/*.log
23+
**/.DS_Store
24+
**/Thumbs.db

.pre-commit-config.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
repos:
2+
- repo: https://github.com/antonbabenko/pre-commit-terraform
3+
rev: v1.96.3
4+
hooks:
5+
- id: terraform_fmt
6+
- id: terraform_docs
7+
- id: terraform_tflint

Containerfile

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Global arguments
2+
ARG BASE_IMAGE=node:lts-alpine
3+
ARG APP_DIR=/usr/src/app
4+
ARG UID=1000
5+
ARG GID=1000
6+
ARG PORT=3000
7+
8+
# Base stage
9+
FROM ${BASE_IMAGE} AS base
10+
ARG APP_DIR
11+
ARG UID
12+
ARG GID
13+
ARG PORT
14+
15+
RUN mkdir -p ${APP_DIR} && \
16+
chown -R ${UID}:${GID} ${APP_DIR}
17+
18+
USER ${UID}:${GID}
19+
20+
WORKDIR ${APP_DIR}
21+
22+
ENV PORT=${PORT}
23+
EXPOSE ${PORT}
24+
25+
COPY --chown=${UID}:${GID} package.json .
26+
27+
# Dependencies stage
28+
FROM base AS dependencies
29+
ARG APP_DIR
30+
31+
RUN npm install && \
32+
npm cache clean --force && \
33+
touch ${APP_DIR}/production.env && \
34+
touch ${APP_DIR}/development.env
35+
36+
ENV PATH=${APP_DIR}/node_modules/.bin:$PATH
37+
38+
# Development stage
39+
FROM dependencies AS development
40+
ARG UID
41+
ARG GID
42+
43+
ENV NODE_ENV=development
44+
45+
COPY --chown=${UID}:${GID} . .
46+
47+
CMD ["npm", "run", "dev"]
48+
49+
# Build stage
50+
FROM dependencies AS build
51+
ARG UID
52+
ARG GID
53+
54+
COPY --chown=${UID}:${GID} . .
55+
56+
RUN npm run build
57+
58+
# Production stage
59+
FROM dependencies AS production
60+
ARG UID
61+
ARG GID
62+
ARG APP_DIR
63+
64+
ENV NODE_ENV=production
65+
66+
COPY --chown=${UID}:${GID} ./public ./public
67+
COPY --chown=${UID}:${GID} ./views ./views
68+
COPY --chown=${UID}:${GID} --from=build ${APP_DIR}/dist ./dist
69+
70+
CMD ["node", "./dist", "--env=production"]

Dockerfile

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Global arguments
2+
ARG BASE_IMAGE=node:lts-alpine
3+
ARG APP_DIR=/usr/src/app
4+
ARG UID=1000
5+
ARG GID=1000
6+
ARG PORT=3000
7+
8+
# Base stage
9+
FROM ${BASE_IMAGE} AS base
10+
ARG APP_DIR
11+
ARG UID
12+
ARG GID
13+
ARG PORT
14+
15+
RUN mkdir -p ${APP_DIR} && \
16+
chown -R ${UID}:${GID} ${APP_DIR}
17+
18+
USER ${UID}:${GID}
19+
20+
WORKDIR ${APP_DIR}
21+
22+
ENV PORT=${PORT}
23+
EXPOSE ${PORT}
24+
25+
# Dependencies stage
26+
FROM base AS dependencies
27+
ARG APP_DIR
28+
29+
RUN --mount=type=bind,source=./package.json,target=${APP_DIR}/package.json \
30+
--mount=type=cache,target=${APP_DIR}/.npm,uid=$UID,gid=$GID,mode=0755,sharing=locked \
31+
npm install && \
32+
touch ${APP_DIR}/production.env && \
33+
touch ${APP_DIR}/development.env
34+
35+
ENV PATH=${APP_DIR}/node_modules/.bin:$PATH
36+
37+
# Development stage
38+
FROM dependencies AS development
39+
ARG UID
40+
ARG GID
41+
42+
ENV NODE_ENV=development
43+
44+
COPY --chown=${UID}:${GID} . .
45+
46+
CMD ["npm", "run", "dev"]
47+
48+
# Build stage
49+
FROM dependencies AS build
50+
ARG UID
51+
ARG GID
52+
53+
COPY --chown=${UID}:${GID} . .
54+
55+
RUN npm run build
56+
57+
# Production stage
58+
FROM dependencies AS production
59+
ARG UID
60+
ARG GID
61+
ARG APP_DIR
62+
63+
ENV NODE_ENV=production
64+
65+
COPY --chown=${UID}:${GID} package.json .
66+
COPY --chown=${UID}:${GID} ./public ./public
67+
COPY --chown=${UID}:${GID} ./views ./views
68+
COPY --chown=${UID}:${GID} --from=build ${APP_DIR}/dist ./dist
69+
70+
CMD ["node", "./dist", "--env=production"]

terraform/.gitignore

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/terraform,osx,linux,windows
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=terraform,osx,linux,windows
3+
4+
### Linux ###
5+
*~
6+
7+
# temporary files which can be created if a process still has a handle open of a deleted file
8+
.fuse_hidden*
9+
10+
# KDE directory preferences
11+
.directory
12+
13+
# Linux trash folder which might appear on any partition or disk
14+
.Trash-*
15+
16+
# .nfs files are created when an open file is removed but is still being accessed
17+
.nfs*
18+
19+
### OSX ###
20+
# General
21+
.DS_Store
22+
.AppleDouble
23+
.LSOverride
24+
25+
# Icon must end with two \r
26+
Icon
27+
28+
29+
# Thumbnails
30+
._*
31+
32+
# Files that might appear in the root of a volume
33+
.DocumentRevisions-V100
34+
.fseventsd
35+
.Spotlight-V100
36+
.TemporaryItems
37+
.Trashes
38+
.VolumeIcon.icns
39+
.com.apple.timemachine.donotpresent
40+
41+
# Directories potentially created on remote AFP share
42+
.AppleDB
43+
.AppleDesktop
44+
Network Trash Folder
45+
Temporary Items
46+
.apdisk
47+
48+
### Terraform ###
49+
# Local .terraform directories
50+
**/.terraform/*
51+
52+
# .tfstate files
53+
*.tfstate
54+
*.tfstate.*
55+
56+
# Crash log files
57+
crash.log
58+
crash.*.log
59+
60+
# Exclude all .tfvars files, which are likely to contain sensitive data, such as
61+
# password, private keys, and other secrets. These should not be part of version
62+
# control as they are data points which are potentially sensitive and subject
63+
# to change depending on the environment.
64+
*.tfvars
65+
*.tfvars.json
66+
67+
# Ignore override files as they are usually used to override resources locally and so
68+
# are not checked in
69+
override.tf
70+
override.tf.json
71+
*_override.tf
72+
*_override.tf.json
73+
74+
# Include override files you do wish to add to version control using negated pattern
75+
# !example_override.tf
76+
77+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
78+
# example: *tfplan*
79+
80+
# Ignore CLI configuration files
81+
.terraformrc
82+
terraform.rc
83+
84+
### Windows ###
85+
# Windows thumbnail cache files
86+
Thumbs.db
87+
Thumbs.db:encryptable
88+
ehthumbs.db
89+
ehthumbs_vista.db
90+
91+
# Dump file
92+
*.stackdump
93+
94+
# Folder config file
95+
[Dd]esktop.ini
96+
97+
# Recycle Bin used on file shares
98+
$RECYCLE.BIN/
99+
100+
# Windows Installer files
101+
*.cab
102+
*.msi
103+
*.msix
104+
*.msm
105+
*.msp
106+
107+
# Windows shortcuts
108+
*.lnk
109+
110+
# End of https://www.toptal.com/developers/gitignore/api/terraform,osx,linux,windows

0 commit comments

Comments
 (0)