-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add devcontainer configuration
- Loading branch information
Showing
26 changed files
with
264 additions
and
80 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,50 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose | ||
{ | ||
"name": "Existing Docker Compose (Extend)", | ||
// 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.yml", | ||
"docker-compose.yml" | ||
], | ||
// 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": "/usr/src/app", | ||
"postCreateCommand": "npm install", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"esbenp.prettier-vscode", | ||
"editorconfig.editorconfig", | ||
"dbaeumer.vscode-eslint", | ||
"wayou.vscode-todo-highlight", | ||
"mike-co.import-sorter", | ||
"waderyan.gitblame", | ||
"ms-vscode.vscode-typescript-tslint-plugin", | ||
"ms-azuretools.vscode-docker" | ||
] | ||
} | ||
}, | ||
"mounts": [ | ||
"source=${localWorkspaceFolder},target=/usr/src/app,type=bind", | ||
"source=node_modules,target=/usr/src/app/node_modules,type=volume" | ||
], | ||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
// 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. | ||
// "postCreateCommand": "cat /etc/os-release", | ||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-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,29 @@ | ||
version: '3.8' | ||
services: | ||
# Update this to the name of the service you want to work with in your docker-compose.yml file | ||
app: | ||
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer | ||
# folder. Note that the path of the Dockerfile and context is relative to the *primary* | ||
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile" | ||
# array). The sample below assumes your primary file is in the root of your project. | ||
# | ||
# build: | ||
# context: . | ||
# dockerfile: .devcontainer/Dockerfile | ||
|
||
volumes: | ||
# Update this to wherever you want VS Code to mount the folder of your project | ||
- ..:/usr/src/app:cached | ||
- node_modules:/usr/src/app/node_modules | ||
|
||
# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust. | ||
# cap_add: | ||
# - SYS_PTRACE | ||
# security_opt: | ||
# - seccomp:unconfined | ||
|
||
# Overrides default command so things don't shut down after the process ends. | ||
command: /bin/sh -c "while sleep 1000; do :; done" | ||
|
||
volumes: | ||
node_modules: |
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
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 |
---|---|---|
|
@@ -392,3 +392,4 @@ dist | |
local/ | ||
documentation | ||
test-report.xml | ||
tsconfig.build.tsbuildinfo |
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 @@ | ||
nodejs 20.14.0 |
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
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,32 +1,30 @@ | ||
# lts-gallium refers to v16 | ||
# Using this instead of node:16 to avoid dependabot updates | ||
FROM node:lts-gallium as builder | ||
# Development Dockerfile | ||
FROM node:20.14.0-bookworm-slim | ||
|
||
# Install additional tools for development | ||
RUN apt-get update && apt-get install -y \ | ||
vim \ | ||
curl \ | ||
wget \ | ||
git \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /usr/src/app | ||
|
||
# Copy and install dependencies | ||
COPY package.json package-lock.json ./ | ||
RUN npm ci | ||
RUN npm install | ||
|
||
# Copy the rest of the application files | ||
COPY . . | ||
|
||
# Set the environment variables | ||
ARG APP_ENV=development | ||
ENV NODE_ENV=${APP_ENV} | ||
|
||
RUN npm run build | ||
|
||
RUN npm prune | ||
|
||
FROM node:lts-gallium | ||
|
||
ARG APP_ENV=development | ||
ENV NODE_ENV=${APP_ENV} | ||
|
||
WORKDIR /usr/src/app | ||
COPY --from=builder /usr/src/app/node_modules ./node_modules | ||
COPY --from=builder /usr/src/app/package*.json ./ | ||
COPY --from=builder /usr/src/app/dist ./dist | ||
|
||
# Expose the application port | ||
EXPOSE 3000 | ||
|
||
USER node | ||
CMD [ "npm", "run", "start:prod" ] | ||
# Set the default command to run the application with nodemon | ||
CMD ["npm", "start:dev"] |
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,42 @@ | ||
# Stage 1: Build the application | ||
FROM node:20.14.0-bookworm-slim as builder | ||
|
||
WORKDIR /usr/src/app | ||
|
||
# Install dependencies | ||
COPY package.json package-lock.json ./ | ||
RUN npm ci | ||
|
||
# Copy the rest of the application files | ||
COPY . . | ||
|
||
# Build the application | ||
ARG APP_ENV=production | ||
ENV NODE_ENV=${APP_ENV} | ||
RUN npm run build | ||
|
||
# Prune development dependencies | ||
RUN npm prune --production | ||
|
||
# Stage 2: Create the production image | ||
FROM node:20.14.0-bookworm-slim | ||
|
||
WORKDIR /usr/src/app | ||
|
||
# Copy only the necessary files from the builder stage | ||
COPY --from=builder /usr/src/app/node_modules ./node_modules | ||
COPY --from=builder /usr/src/app/package*.json ./ | ||
COPY --from=builder /usr/src/app/dist ./dist | ||
|
||
# Set the environment variables | ||
ARG APP_ENV=production | ||
ENV NODE_ENV=${APP_ENV} | ||
|
||
# Expose the application port | ||
EXPOSE 3000 | ||
|
||
# Use a non-root user for security | ||
USER node | ||
|
||
# Set the default command to run the application | ||
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
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
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
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
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
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
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
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
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
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.