Skip to content

Commit

Permalink
Merge pull request #60 from pinceladasdaweb/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
pinceladasdaweb authored Sep 11, 2022
2 parents eb7a870 + c0a6b91 commit 27633f3
Show file tree
Hide file tree
Showing 10 changed files with 2,415 additions and 4,330 deletions.
19 changes: 7 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
FROM node:16.14.0-alpine
FROM node:16.17.0-alpine

LABEL maintainer="Pedro Rogério"

# Set the working directory
WORKDIR /usr/src/app

# Copy source code
COPY package*.json ./
COPY --chown=node:node package*.json ./

# Running npm install
RUN npm install --only=production
RUN npm ci --omit=dev --ignore-scripts && npm cache clean --force

# Copy the rest of your app's source code from your host to your image filesystem.
COPY . .
COPY --chown=node:node . .

# Create a user group 'nodegroup', create a user 'nodeuser' under 'nodegroup' and chown all the files to the app user.
RUN addgroup -S nodegroup && \
adduser -S -D -h /usr/src/app nodeuser nodegroup && \
chown -R nodeuser:nodegroup /usr/src

# Switch to 'nodeuser'
USER nodeuser
# Switch to 'node' user
USER node

# Open the mapped port
EXPOSE 3000

CMD [ "node", "src/index.js" ]
CMD ["node", "src/index.js"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
DOCKER := @docker
COMPOSE := @docker-compose
NODE := 16.14.0-alpine
NODE := 16.17.0-alpine

help: ## Show this help message.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Node.js RESTful API boilerplate using Traefik, Docker, Docker Compose, Fastify, JWT and Mongodb.

## Requirements
1. Node.js >= 14
1. Node.js >= 16
2. Docker
3. Docker compose

Expand Down Expand Up @@ -103,9 +103,8 @@ http://localhost:8080

![](/traefik.png)

Happy coding!

## Infrastructure model

### Infrastructure model
![Infrastructure model](.infragenie/infrastructure_model.png)

![Infrastructure model](.infragenie/infrastructure_model.png)
Happy coding!
12 changes: 10 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ version: '3.7'
services:
api:
container_name: api
image: node:16.14.0-alpine
image: node:16.17.0-alpine
working_dir: /usr/src/app
ports:
- '3000:3000'
command: npm run dev
command: >
/bin/sh -c "
echo Waiting for mongodb service start...;
while ! nc -z mongo 27017;
do
sleep 1;
done;
npm run dev
"
init: true
volumes:
- .:/usr/src/app
Expand Down
Loading

0 comments on commit 27633f3

Please sign in to comment.