-
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
776f537
commit 7c7e2f1
Showing
4 changed files
with
73 additions
and
1 deletion.
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,7 @@ | ||
.gitignore | ||
dockerfile | ||
node_modules | ||
.git | ||
.gitignore | ||
*.md | ||
dist |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
services: | ||
mongodb: | ||
image: mongodb/mongodb-community-server:latest | ||
container_name: mongodb | ||
ports: | ||
- "27017:27017" # Expose MongoDB port | ||
environment: | ||
MONGO_INITDB_ROOT_USERNAME: admin | ||
MONGO_INITDB_ROOT_PASSWORD: secret | ||
networks: | ||
- express_api_network | ||
volumes: | ||
- mongodb_data:/data/db # Volume for persistent data | ||
|
||
app: | ||
build: | ||
context: . # Directory containing the Dockerfile | ||
dockerfile: dockerfile # Specify the Dockerfile name if it's not the default | ||
container_name: express-ts-api | ||
ports: | ||
- "8080:8080" # Expose the app port | ||
environment: | ||
MONGO_URI: mongodb://admin:secret@mongodb:27017/collections?authSource=admin # Connection URI | ||
depends_on: | ||
- mongodb # Ensure MongoDB starts before the app | ||
networks: | ||
- express_api_network | ||
|
||
networks: | ||
express_api_network: | ||
driver: bridge # Create a bridge network | ||
|
||
volumes: | ||
mongodb_data: |
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,28 @@ | ||
# Step 1: Use Node.js as the base image | ||
FROM node:22-alpine | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
# Step 2: Install pnpm globally | ||
RUN npm install -g pnpm | ||
|
||
# Step 3: Set the working directory in the container | ||
WORKDIR /usr/src/app | ||
|
||
# Step 4: Copy the package.json and pnpm-lock.yaml files | ||
COPY package.json pnpm-lock.yaml ./ | ||
|
||
# Step 5: Install the dependencies using pnpm | ||
RUN pnpm install | ||
|
||
# Step 6: Copy the rest of the application code | ||
COPY . . | ||
|
||
# Step 7: Install TypeScript and compile the TypeScript files | ||
RUN pnpm add -g typescript | ||
RUN tsc | ||
|
||
# Step 8: Expose the port the app runs on (adjust if different) | ||
EXPOSE 8080 | ||
|
||
# Step 9: Start the application | ||
CMD ["node", "src/index.js"] |