Skip to content

Commit

Permalink
Create backend app with expressjs api
Browse files Browse the repository at this point in the history
  • Loading branch information
ernitingarg committed Jan 8, 2024
1 parent 7ce24de commit 8322f17
Show file tree
Hide file tree
Showing 9 changed files with 2,099 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules
# CDK asset staging directory
.cdk.staging
cdk.out
.env
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ npm install -D ts-node ts-node-dev typescript @types/express @types/dotenv @type
npm install -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
```

- Run backend app locally

```
cd backend
npm install
npm run start
# watch mode
npm run start:dev
```

- Run backend docker app locally

```
cd backend
docker build -t backend_image .
docker run -p 3000:3000 --name backend_app backend_image
```

## Useful commands

- `npm run build` compile typescript to js
Expand Down
2 changes: 2 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.env
21 changes: 21 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Use node.js image as base
FROM node:latest

# Set working directory inside the container
WORKDIR /app

# Copy package.json to the working directory
COPY package.json .

# Install dependencies
RUN npm install

# Copy everything
COPY . .

# Expose the port specified in the .env file
ENV PORT=${PORT}
EXPOSE $PORT

# Command to run the application
CMD ["npm", "start"]
Loading

0 comments on commit 8322f17

Please sign in to comment.