Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Romain Barissat <[email protected]>
  • Loading branch information
politician committed Oct 27, 2021
0 parents commit 8cae852
Show file tree
Hide file tree
Showing 13 changed files with 1,704 additions and 0 deletions.
200 changes: 200 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
##--------------------------------------------------------------------------------
## MacOS
## https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
##--------------------------------------------------------------------------------
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

##--------------------------------------------------------------------------------
## Linux
## https://github.com/github/gitignore/blob/master/Global/Linux.gitignore
##--------------------------------------------------------------------------------
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

##--------------------------------------------------------------------------------
## Windows
## https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
##--------------------------------------------------------------------------------
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

##--------------------------------------------------------------------------------
## Node.js
## https://github.com/github/gitignore/blob/master/Node.gitignore
##--------------------------------------------------------------------------------
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test
.env.production

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
36 changes: 36 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Local: Attach to Node.js",
"type": "node",
"request": "attach",
"port": 9229,
"restart": true,
"skipFiles": ["<node_internals>/**"]
},
{
"name": "Docker: Attach to Node.js",
"type": "node",
"request": "attach",
"port": 9230,
"restart": true,
"skipFiles": ["<node_internals>/**"],
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app"
},
{
"name": "K8s: Attach to Node.js",
"type": "node",
"request": "attach",
"port": 9231,
"restart": true,
"skipFiles": ["<node_internals>/**"],
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app"
}
]
}
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This is a multi-stage build
# https://docs.docker.com/develop/develop-images/multistage-build/

# Stage 1: Use an image containing all the bells and whistles needed to build a NodeJS app
# This is the image used for local development
FROM node:16 AS dev
ARG node_env=production
ENV NODE_ENV $node_env
WORKDIR /app
COPY package*.json yarn.lock ./
RUN yarn install --frozen-lockfile
COPY src ./src
EXPOSE 3000
EXPOSE 9229
# We suppose that any build targeting dev will use node_env=development or will change the entrypoint
ENTRYPOINT ["./node_modules/nodemon/bin/nodemon.js"]
CMD ["--inspect=0.0.0.0", "src/index.js"]

# Stage 2: Use a debug distroless image and copy only the folder containing the build
# This is the image used for debugging prod-like containers
FROM gcr.io/distroless/nodejs:16-debug AS debug
WORKDIR /app
COPY --from=dev /app/node_modules /app/
COPY --from=dev /app/src /app
EXPOSE 3000
EXPOSE 9229
USER nonroot
CMD ["--inspect=0.0.0.0", "index.js"]

# Stage 3: Use a production distroless image and copy only the folder containing the build
# This is the image that is retained to be published to the registry if no build target is specified
# It should be used for production
FROM gcr.io/distroless/nodejs:16 AS prod
WORKDIR /app
COPY --from=debug /app /app
EXPOSE 3000
USER nonroot
CMD ["index.js"]
Loading

0 comments on commit 8cae852

Please sign in to comment.