mirror of https://github.com/YunYouJun/valaxy
docs: add how to deploy with docker
This commit is contained in:
parent
916524e567
commit
295441281f
|
@ -15,9 +15,9 @@ Valaxy 的部署非常简单,我们推荐你直接通过第三方的 CI 构建
|
|||
Deploying Valaxy is very easy. We suggest that you build and deploy to any platform using third party CI.
|
||||
:::
|
||||
|
||||
### 自行部署 {lang="zh-CN"}
|
||||
## 自行部署 {lang="zh-CN"}
|
||||
|
||||
### Manual Deployment {lang="en"}
|
||||
## Manual Deployment {lang="en"}
|
||||
|
||||
::: zh-CN
|
||||
|
||||
|
@ -39,11 +39,27 @@ npm run build
|
|||
|
||||
:::
|
||||
|
||||
### 第三方部署 {lang="zh-CN"}
|
||||
## 第三方部署 {lang="zh-CN"}
|
||||
|
||||
### Third Party Deployment {lang="en"}
|
||||
## Third Party Deployment {lang="en"}
|
||||
|
||||
#### GitHub Pages
|
||||
::: tip
|
||||
|
||||
<div lang="zh-CN">
|
||||
|
||||
第三方部署的各配置文件已内置在 Valaxy 的初始化模版项目中,您可以按需使用。
|
||||
|
||||
</div>
|
||||
|
||||
<div lang="en">
|
||||
|
||||
The configuration files for the following third-party deployments are built into the Valaxy template project. You can use them as needed.
|
||||
|
||||
</div>
|
||||
|
||||
:::
|
||||
|
||||
### GitHub Pages
|
||||
|
||||
<BrandIcon icon="i-logos:github-icon" link="https://pages.github.com/" />
|
||||
|
||||
|
@ -71,7 +87,7 @@ When you use `pnpm create valaxy` to create a template project, it contains the
|
|||
|
||||
:::
|
||||
|
||||
#### Netlify
|
||||
### Netlify
|
||||
|
||||
<BrandIcon icon="i-logos:netlify-icon" link="https://www.netlify.com/" />
|
||||
|
||||
|
@ -85,7 +101,7 @@ When you use `pnpm create valaxy` to create a template project, it contains the
|
|||
`netlify.toml` is built-in.
|
||||
:::
|
||||
|
||||
#### Vercel
|
||||
### Vercel
|
||||
|
||||
<BrandIcon icon="i-logos:vercel-icon" link="https://vercel.com/" />
|
||||
|
||||
|
@ -115,7 +131,7 @@ When you use `pnpm create valaxy` to create a template project, it contains the
|
|||
- Wait for ribbons to drop on the screen, then visit your website.
|
||||
:::
|
||||
|
||||
#### Cloudflare Pages
|
||||
### Cloudflare Pages
|
||||
|
||||
<BrandIcon icon="i-logos:cloudflare-icon" link="https://pages.cloudflare.com/" />
|
||||
|
||||
|
@ -145,19 +161,19 @@ When you use `pnpm create valaxy` to create a template project, it contains the
|
|||
- Then click "Save and Deploy".
|
||||
:::
|
||||
|
||||
#### Nginx
|
||||
### Nginx
|
||||
|
||||
> [Nginx Docs](https://nginx.org/en/docs/)
|
||||
|
||||
::: zh-CN
|
||||
|
||||
下面是一个 Nginx 服务器块配置示例。此配置包括对基于文本的常见资源的 gzip 压缩、使用适当缓存头为 Valaxy 站点静态文件提供服务的规则以及处理 `cleanUrls: true` 的方法。
|
||||
下面是一个 Nginx 服务器块配置示例 `nginx.conf`。此配置包括对基于文本的常见资源的 gzip 压缩、使用适当缓存头为 Valaxy 站点静态文件提供服务的规则以及处理 `cleanUrls: true` 的方法。
|
||||
|
||||
:::
|
||||
|
||||
::: en
|
||||
|
||||
Here is an example of an Nginx server block configuration. This configuration includes rules for gzip compression of common text-based resources, serving static files for a Valaxy site with appropriate caching headers, and handling `cleanUrls: true`.
|
||||
Here is an example of an Nginx server block configuration `nginx.conf`. This configuration includes rules for gzip compression of common text-based resources, serving static files for a Valaxy site with appropriate caching headers, and handling `cleanUrls: true`.
|
||||
|
||||
:::
|
||||
|
||||
|
@ -172,7 +188,8 @@ server {
|
|||
|
||||
location / {
|
||||
# content location
|
||||
root /app;
|
||||
# root /app;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
# exact matches -> reverse clean urls -> folders -> not found
|
||||
try_files $uri $uri.html $uri/ =404;
|
||||
|
@ -195,19 +212,61 @@ server {
|
|||
|
||||
::: zh-CN
|
||||
|
||||
本配置默认已构建的 Valaxy 站点位于服务器上的 `/app` 目录中。如果站点文件位于其他位置,请相应调整 `root` 指令。
|
||||
本配置默认已构建的 Valaxy 站点位于服务器上的 `/usr/share/nginx/html` 目录中。如果站点文件位于其他位置,请相应调整 `root` 指令。
|
||||
|
||||
:::
|
||||
|
||||
::: en
|
||||
|
||||
This configuration assumes that the built Valaxy site is located in the `/app` directory on the server. If your site files are located elsewhere, adjust the `root` directive accordingly.
|
||||
This configuration assumes that the built Valaxy site is located in the `/usr/share/nginx/html` directory on the server. If your site files are located elsewhere, adjust the `root` directive accordingly.
|
||||
|
||||
:::
|
||||
|
||||
#### 其他 {lang="zh-CN"}
|
||||
### Docker
|
||||
|
||||
#### Others {lang="en"}
|
||||
> [Docker Docs](https://docs.docker.com/)
|
||||
|
||||
::: zh-CN
|
||||
|
||||
下面是一个 Dockerfile 示例,用于构建 Valaxy 站点并将其部署到 Nginx 服务器中。
|
||||
|
||||
请参考 Nginx 部分配置 `nginx.conf`,并将其放置于 `Dockerfile` 同一目录下。
|
||||
|
||||
:::
|
||||
|
||||
::: en
|
||||
|
||||
Here is an example Dockerfile for building a Valaxy site and deploying it to an Nginx server.
|
||||
|
||||
Refer to the Nginx section for the `nginx.conf` configuration and place it in the same directory as the `Dockerfile`.
|
||||
|
||||
:::
|
||||
|
||||
```Dockerfile
|
||||
FROM node:20-alpine as build-stage
|
||||
|
||||
WORKDIR /app
|
||||
RUN corepack enable
|
||||
|
||||
COPY .npmrc package.json pnpm-lock.yaml ./
|
||||
RUN --mount=type=cache,id=pnpm-store,target=/root/.pnpm-store \
|
||||
pnpm install --frozen-lockfile
|
||||
|
||||
COPY . .
|
||||
RUN pnpm build
|
||||
|
||||
FROM nginx:stable-alpine as production-stage
|
||||
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
```
|
||||
|
||||
### 其他 {lang="zh-CN"}
|
||||
|
||||
### Others {lang="en"}
|
||||
|
||||
<BrandIcon class="text-xl!" icon="i-simple-icons-render" link="https://render.com/" />
|
||||
|
||||
|
|
|
@ -3,15 +3,16 @@ FROM node:20-alpine as build-stage
|
|||
WORKDIR /app
|
||||
RUN corepack enable
|
||||
|
||||
COPY .npmrc package.json ./
|
||||
COPY .npmrc package.json pnpm-lock.yaml ./
|
||||
RUN --mount=type=cache,id=pnpm-store,target=/root/.pnpm-store \
|
||||
pnpm install
|
||||
pnpm install --frozen-lockfile
|
||||
|
||||
COPY . .
|
||||
RUN pnpm build
|
||||
|
||||
FROM nginx:stable-alpine as production-stage
|
||||
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
||||
EXPOSE 80
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
server {
|
||||
gzip on;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
listen 80;
|
||||
server_name _;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
# content location
|
||||
# root /app;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
# exact matches -> reverse clean urls -> folders -> not found
|
||||
try_files $uri $uri.html $uri/ =404;
|
||||
|
||||
# non existent pages
|
||||
error_page 404 /404.html;
|
||||
|
||||
# a folder without index.html raises 403 in this setup
|
||||
error_page 403 /404.html;
|
||||
|
||||
# adjust caching headers
|
||||
# files in the assets folder have hashes filenames
|
||||
location ~* ^/assets/ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue