chore: fix container build and minimize container size (#380)
This commit is contained in:
parent
4d6d9b9d2f
commit
0c36f39514
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
node_modules
|
||||||
|
dist
|
19
Dockerfile
19
Dockerfile
@ -1,7 +1,18 @@
|
|||||||
FROM node:16-alpine
|
FROM node:16-alpine as build-stage
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
RUN corepack enable
|
RUN corepack enable
|
||||||
WORKDIR /root/app
|
|
||||||
|
COPY .npmrc package.json pnpm-lock.yaml ./
|
||||||
|
RUN --mount=type=cache,id=pnpm-store,target=/root/.pnpm-store \
|
||||||
|
pnpm install --frozen-lockfile
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN pnpm i --prod
|
|
||||||
RUN pnpm build
|
RUN pnpm build
|
||||||
CMD pnpm preview --host
|
|
||||||
|
FROM nginx:stable-alpine as production-stage
|
||||||
|
|
||||||
|
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
12
README.md
12
README.md
@ -191,14 +191,18 @@ And you will see the generated file in `dist` that ready to be served.
|
|||||||
|
|
||||||
Go to [Netlify](https://app.netlify.com/start) and select your clone, `OK` along the way, and your App will be live in a minute.
|
Go to [Netlify](https://app.netlify.com/start) and select your clone, `OK` along the way, and your App will be live in a minute.
|
||||||
|
|
||||||
### Docker
|
### Docker Production Build
|
||||||
First, build the vitesse image by opening the terminal in the project's root directory.
|
|
||||||
|
First, build the vitesse image by opening the terminal in the project's root directory.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker build . -t vitesse
|
docker build . -t vitesse:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
Run the image and specify port mapping with the `-p` flag.
|
Run the image and specify port mapping with the `-p` flag.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -p 4173:4173 vitesse
|
docker run --rm -it -p 8080:80 vitesse:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
## Why
|
## Why
|
||||||
|
Loading…
Reference in New Issue
Block a user