-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f0425a
commit b9f62eb
Showing
17 changed files
with
9,239 additions
and
6,124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/docker-existing-docker-compose | ||
// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml. | ||
{ | ||
"name": "Natours", | ||
// Update the 'dockerComposeFile' list if you have more compose files or use different names. | ||
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make. | ||
"dockerComposeFile": [ | ||
"../docker-compose.dev.yaml" | ||
], | ||
// The 'service' property is the name of the service for the container that VS Code should | ||
// use. Update this value and .devcontainer/docker-compose.yml to the real service name. | ||
"service": "app", | ||
// The optional 'workspaceFolder' property is the path VS Code should open by default when | ||
// connected. This is typically a file mount in .devcontainer/docker-compose.yml | ||
"workspaceFolder": "/home/node/app", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"dbaeumer.vscode-eslint", | ||
"esbenp.prettier-vscode", | ||
"ms-vscode.vscode-typescript-tslint-plugin", | ||
"msjsdiag.vscode-react-native", | ||
"octref.vetur", | ||
"PKief.material-icon-theme", | ||
"ritwickdey.LiveServer", | ||
"vuetifyjs.vuetify-vscode", | ||
"johnpapa.vscode-peacock", | ||
"pugbeautify.vscode-pugbeautify", | ||
"firsttris.vscode-jest-runner", | ||
"humao.rest-client", | ||
"mikestead.dotenv", | ||
"digitalbrainstem.javascript-ejs-support", | ||
"dsznajder.es7-react-js-snippets", | ||
"github.remotehub", | ||
"equinusocio.vsc-material-theme", | ||
"equinusocio.vsc-material-theme-icons", | ||
"ms-vscode-remote.vscode-remote-extensionpack", | ||
"vscode.remote-explorer", | ||
"wayou.vscode-todo-highlight", | ||
"naumovs.color-highlight", | ||
"pranaygp.vscode-css-peek", | ||
"github.vscode-pull-request-github", | ||
"codezombiech.gitignore", | ||
"eamodio.gitlens", | ||
"kisstkondoros.vscode-gutter-preview", | ||
"ms-kubernetes-tools.vscode-kubernetes-tools", | ||
"ritwickdey.liveserver", | ||
"mongodb.mongodb-vscode", | ||
"analytic-signal.preview-pdf", | ||
"redhat.vscode-yaml" | ||
] | ||
} | ||
} | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
// Uncomment the next line if you want start specific services in your Docker Compose config. | ||
// "runServices": [], | ||
// Uncomment the next line if you want to keep your containers running after VS Code shuts down. | ||
// "shutdownAction": "none", | ||
// Uncomment the next line to run commands after the container is created - for example installing curl. | ||
// "postCreateCommand": "apt-get update && apt-get install -y curl", | ||
// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root. | ||
// "remoteUser": "vscode" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
npm install | ||
|
||
#npm audit fix --force | ||
|
||
#tail -f /dev/null -> Este comando 'mantem o container de pé' | ||
# para evitar que o container termine após finalizar todos os comandos. | ||
# Neste caso não estamos iniciando a aplicação (start). | ||
tail -f /dev/null |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.history/ | ||
.docker/dbdata/ | ||
.docker/zsh | ||
.devcontainer/ | ||
.git/ | ||
.github/ | ||
dist/ | ||
node_modules/ | ||
npm-debug.log | ||
docker-compose.dev.yaml | ||
docker-compose.prod.yaml | ||
Dockerfile.dev | ||
Dockerfile.prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
node_modules/ | ||
.cache/ | ||
*.env | ||
node_modules/ | ||
.cache/ | ||
.docker/dbdata/ | ||
.docker/zsh/history/ | ||
*.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
// 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": [ | ||
{ | ||
// 1. Type of application to attach to | ||
"type": "node", | ||
// 2. Type of request. In this case 'attach' | ||
"request": "attach", | ||
// 3. Restart the debugger whenever it gets disconnected | ||
"restart": true, | ||
// 4. Port to connect to | ||
"port": 9229, | ||
// 5. Name of the configuration | ||
"name": "Docker: Attach to Node", | ||
// 6. Connect to /node directory of docker | ||
"remoteRoot": "/home/node/app" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# FROM node:16.16.0-slim | ||
FROM node:18-slim | ||
|
||
RUN apt update && apt install -y \ | ||
git \ | ||
gpg \ | ||
gnupg \ | ||
gpg-agent \ | ||
socat \ | ||
ca-certificates \ | ||
zsh \ | ||
curl \ | ||
wget \ | ||
fonts-powerline \ | ||
procps | ||
|
||
RUN npm install -g nodemon | ||
|
||
USER node | ||
#Delimitar um usuário não root | ||
#Princípio do mínimo privilégio | ||
|
||
RUN mkdir -p /home/node/app | ||
|
||
WORKDIR /home/node/app | ||
|
||
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.2/zsh-in-docker.sh)" -- \ | ||
-t https://github.com/romkatv/powerlevel10k \ | ||
-p git \ | ||
-p git-flow \ | ||
-p https://github.com/zdharma-continuum/fast-syntax-highlighting \ | ||
-p https://github.com/zsh-users/zsh-autosuggestions \ | ||
-p https://github.com/zsh-users/zsh-completions \ | ||
-a 'export TERM=xterm-256color' | ||
|
||
RUN echo '[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh' >> ~/.zshrc && \ | ||
echo 'HISTFILE=/home/node/zsh/.zsh_history' >> ~/.zshrc | ||
|
||
# COPY --chown=node:node package.json package-lock.json ./ | ||
# RUN npm install -g nodemon | ||
# RUN npm install | ||
# RUN npm audit fix --force | ||
# CMD [ "tail", "-f", "/dev/null" ] | ||
|
||
# CMD é executado APÓS o container ter iniciado | ||
CMD [ ".docker/start.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
FROM node:16.16.0-slim as testing | ||
|
||
USER node | ||
RUN mkdir -p /home/node/app | ||
WORKDIR /home/node/app | ||
|
||
# COPY/NPM CI -> Feito em duas etapas para otimizar o processo de instalação. Neste caso há o uso/reaproveitamento de cache. | ||
COPY --chown=node:node package.json package-lock.json ./ | ||
# RUN npm ci -> Faz instalações mais eficientes a partir do package-lock.json tanto prod quanto dev | ||
RUN npm ci | ||
|
||
COPY --chown=node:node . . | ||
RUN npm run build | ||
|
||
ENV NODE_ENV=production | ||
CMD [ "npm", "run", "start:prod" ] | ||
|
||
# Multi Stage - Descartar [Total ou em partes] os builds anteriores | ||
FROM node:16.16.0-slim as production | ||
|
||
USER node | ||
RUN mkdir -p /home/node/app | ||
WORKDIR /home/node/app | ||
|
||
# Reaproveita os arquivos gerados no estágio anterior(testing) | ||
COPY --from=testing --chown=node:node /home/node/app/package*.json ./ | ||
# --omit=dev significa que não será instalado (devDependencies) | ||
RUN npm ci --omit=dev | ||
|
||
COPY --from=testing --chown=node:node /home/node/app . | ||
|
||
EXPOSE 3000 | ||
|
||
ENV NODE_ENV=production | ||
CMD [ "npm", "run", "start:prod" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.