Skip to content

Commit

Permalink
Rework docker and git support files
Browse files Browse the repository at this point in the history
  • Loading branch information
megastary committed Oct 27, 2023
1 parent 57d44a2 commit b71b3c1
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 51 deletions.
22 changes: 10 additions & 12 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
.git
.github
.vscode
build-deps
**/node_modules/
test

.dockerignore
.env
.env.test
.eslintignore
.eslintrc.yml
.eslintrc.yml.hardcore
.git
.gitattributes
.github
.gitignore
.mergify.yml
.travis.yml
.vscode
CODE_OF_CONDUCT.md
CONTRIBUTING.md
*.md
dev.example.env
dev.example.docker-compose.yaml
Dockerfile
README.md


node_modules
npm-debug.log
build-deps
66 changes: 51 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
# Config
config/config.js
config/*.pem

# Database Backups
database-backup/*.tar.gz

# Logs
logs/*.log
logs/*.json
*.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
Expand Down Expand Up @@ -49,8 +42,8 @@ build/Release
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo
Expand All @@ -61,6 +54,15 @@ typings/
# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

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

# Optional REPL history
.node_repl_history

Expand All @@ -70,22 +72,41 @@ typings/
# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
# dotenv environment variable files
.env
docker-compose.dev.yaml
.env.development.local
.env.test.local
.env.production.local
.env.local

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

# next.js build output
# Next.js build output
.next
out

# nuxt.js build output
# 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

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

Expand All @@ -94,4 +115,19 @@ docker-compose.dev.yaml

# DynamoDB Local files
.dynamodb/
.env

# 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.*

# Docker compose
docker-compose.dev.yaml
28 changes: 5 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
FROM houbystudio/base-small-business-fridge:2023-10-17
FROM houbystudio/base-small-business-fridge:2023-10-27

# Create app directory
WORKDIR /usr/src/app

# Set default ENV variables
ENV NODE_ENV=production
ENV DEBUG=false
# Copy default .env
COPY build-deps/defaults.env .env

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
Expand All @@ -14,22 +10,8 @@ COPY package*.json ./
# If you are building your code for production
RUN npm ci --only=production

# Bundle app source
COPY defaults.env .env
# Copy source code
COPY . .

# Change ownership for writeable folders to node user
RUN chown -R node:node /usr/src/app/public/images
RUN chown -R node:node /usr/src/app/database-backup
RUN chown -R node:node /usr/src/app/logs

# Do not run under root
USER node

# Port to expose in container
EXPOSE 3000

# Wrap process within simple init
ENTRYPOINT ["/sbin/tini", "--"]
# Run node app
CMD [ "node", "bin/www" ]
RUN chown -R node:node /usr/src/app/{public/images,database-backup,logs}
15 changes: 15 additions & 0 deletions build-deps/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,18 @@ FROM node:18.18.2-alpine3.17
RUN apk update && apk upgrade

RUN apk add --no-cache mongodb-tools tini tzdata

# Create app directory
WORKDIR /usr/src/app

# Port to expose in container
EXPOSE 3000

# Wrap process within simple init
ENTRYPOINT ["/sbin/tini", "--"]
# Run node app
CMD [ "node", "bin/www" ]

# Set default ENV variables
ENV NODE_ENV=production
ENV DEBUG=false
2 changes: 1 addition & 1 deletion defaults.env → build-deps/defaults.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
NODE_ENV=production
DEBUG=false
APP_PORT=3000
APP_PORT_SSL=443
APP_RATE_LIMIT_PER_MIN=25
Expand All @@ -7,7 +8,6 @@ DB_CONNECTION_STRING=mongodb+srv://usr:[email protected]/sbf?retryWrites=true&w=ma
COOKIE_SECRET=
PARSER_SECRET=
API_SECRET=
DEBUG=false
MAIL_PORT=25
MAIL_HOST={mailserver}
MAIL_FROM=Small Business Fridge
Expand Down
File renamed without changes.

0 comments on commit b71b3c1

Please sign in to comment.