Skip to content

Commit 46750b6

Browse files
author
bekir_filics
committed
enh: add docker for production and development
1 parent 990e948 commit 46750b6

File tree

4 files changed

+65
-1
lines changed

4 files changed

+65
-1
lines changed

Dockerfile.dev

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use the official Node.js image from the Docker Hub
2+
FROM node:14
3+
4+
# Set the working directory inside the container
5+
WORKDIR /app
6+
7+
# Copy package.json and package-lock.json to the working directory
8+
COPY package*.json ./
9+
10+
# Install the dependencies
11+
RUN npm install
12+
13+
# Copy the rest of the application code to the working directory
14+
COPY . .
15+
16+
# Expose the port the app runs on
17+
EXPOSE 8080
18+
19+
# Define the command to run the application
20+
CMD ["npm", "run", "dev"]

Dockerfile.prod

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Use the official Node.js image from the Docker Hub
2+
FROM node:14
3+
4+
# Set the working directory inside the container
5+
WORKDIR /app
6+
7+
# Copy package.json and package-lock.json to the working directory
8+
COPY package*.json ./
9+
10+
# Install only production dependencies
11+
RUN npm install
12+
13+
# Copy the rest of the application code to the working directory
14+
COPY . .
15+
16+
# Build the application
17+
RUN npm run build:bundle
18+
19+
# Expose the port the app runs on
20+
EXPOSE 4173
21+
22+
# Define the command to run the application in production mode
23+
CMD ["npm", "run", "preview"]

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,25 @@ protocol websockets
4242
allow_anonymous true
4343
```
4444

45+
## Docker
46+
### Development
47+
Building docker container for development.
48+
```
49+
docker build -t vda-visualizer:dev -f Dockerfile.dev .
50+
```
51+
52+
Run docker container
53+
```
54+
docker run -p 8080:8080 -v $(pwd):/app -v /app/node_modules --rm vda-visualizer:dev
55+
```
4556

57+
### Production
58+
Building docker container for production
59+
```
60+
docker build -t vda-visualizer:prod -f Dockerfile.prod .
61+
```
62+
63+
Run docker container
64+
```
65+
docker run -p 4173:4173 --rm vda-visualizer:prod
66+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"scripts": {
55
"dev": "vite --host --port 8080",
66
"build:bundle": "vite build",
7-
"preview": "vite preview",
7+
"preview": "vite preview --host",
88
"test:unit": "vitest --environment jsdom",
99
"type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
1010
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .eslintignore"

0 commit comments

Comments
 (0)