mirror of
https://github.com/versia-pub/frontend.git
synced 2025-12-06 08:28:20 +01:00
ci(build): 💚 Use static web server in Docker container
This commit is contained in:
parent
d9283e4c7e
commit
80ad22c395
15
Dockerfile
15
Dockerfile
|
|
@ -1,4 +1,4 @@
|
||||||
FROM imbios/bun-node:22-alpine AS base
|
FROM oven/bun:1.1.38-alpine AS base
|
||||||
|
|
||||||
# Install dependencies into temp directory
|
# Install dependencies into temp directory
|
||||||
# This will cache them and speed up future builds
|
# This will cache them and speed up future builds
|
||||||
|
|
@ -6,18 +6,20 @@ FROM base AS install
|
||||||
|
|
||||||
RUN mkdir -p /temp/dev
|
RUN mkdir -p /temp/dev
|
||||||
COPY package.json bun.lockb /temp/dev/
|
COPY package.json bun.lockb /temp/dev/
|
||||||
RUN cd /temp/dev && bun install --frozen-lockfile
|
RUN cd /temp/dev && bun install --production --frozen-lockfile
|
||||||
|
|
||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
|
|
||||||
COPY . /app
|
COPY . /app
|
||||||
COPY --from=install /temp/dev/node_modules /app/node_modules
|
COPY --from=install /temp/dev/node_modules /app/node_modules
|
||||||
RUN cd /app && bun run emojis:generate
|
RUN cd /app && bun run emojis:generate
|
||||||
RUN cd /app && bun run build --preset bun
|
RUN cd /app && bun run build
|
||||||
|
|
||||||
FROM oven/bun:1.1.38-alpine AS final
|
# Run final web server
|
||||||
|
FROM ghcr.io/static-web-server/static-web-server:2-alpine AS final
|
||||||
|
|
||||||
COPY --from=builder /app/.output/ /app
|
COPY --from=builder /app/.output/public /app/public
|
||||||
|
COPY sws.toml /etc/config.toml
|
||||||
|
|
||||||
LABEL org.opencontainers.image.authors="Gaspard Wierzbinski (https://cpluspatch.com)"
|
LABEL org.opencontainers.image.authors="Gaspard Wierzbinski (https://cpluspatch.com)"
|
||||||
LABEL org.opencontainers.image.source="https://github.com/versia-pub/frontend"
|
LABEL org.opencontainers.image.source="https://github.com/versia-pub/frontend"
|
||||||
|
|
@ -27,4 +29,5 @@ LABEL org.opencontainers.image.title="Versia-FE"
|
||||||
LABEL org.opencontainers.image.description="Frontend for the Versia Server Project"
|
LABEL org.opencontainers.image.description="Frontend for the Versia Server Project"
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
CMD ["bun", "run", "server/index.mjs"]
|
EXPOSE 3000
|
||||||
|
CMD ["static-web-server", "--config-file", "/etc/config.toml"]
|
||||||
19
README.md
19
README.md
|
|
@ -83,6 +83,25 @@ Then, the frontend will be available at `http://localhost:3000` inside the conta
|
||||||
>
|
>
|
||||||
> You can set the `NUXT_PUBLIC_API_HOST` environment variable to point to a different Versia Server instance.
|
> You can set the `NUXT_PUBLIC_API_HOST` environment variable to point to a different Versia Server instance.
|
||||||
|
|
||||||
|
#### Manual
|
||||||
|
|
||||||
|
1. Clone the repository.
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/versia-pub/frontend.git
|
||||||
|
```
|
||||||
|
2. Install dependencies.
|
||||||
|
```bash
|
||||||
|
bun install
|
||||||
|
```
|
||||||
|
3. Build the project.
|
||||||
|
```bash
|
||||||
|
bun run build
|
||||||
|
```
|
||||||
|
4. Serve the static files in the `.output/public` directory.
|
||||||
|
> [!WARNING]
|
||||||
|
>
|
||||||
|
> `.output/public/200.html` should be configured as a fallback for all 404 errors.
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
Run `bun run emojis:generate` to generate the emoji list before building or running the project.
|
Run `bun run emojis:generate` to generate the emoji list before building or running the project.
|
||||||
|
|
|
||||||
23
sws.toml
Normal file
23
sws.toml
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
[general]
|
||||||
|
|
||||||
|
#### Address & Root dir
|
||||||
|
host = "::"
|
||||||
|
port = 3000
|
||||||
|
root = "/app/public"
|
||||||
|
|
||||||
|
#### Logging
|
||||||
|
log-level = "error"
|
||||||
|
|
||||||
|
#### Cache Control headers
|
||||||
|
cache-control-headers = true
|
||||||
|
|
||||||
|
#### Auto Compression
|
||||||
|
compression = true
|
||||||
|
compression-level = "default"
|
||||||
|
|
||||||
|
#### Error pages
|
||||||
|
# Note: If a relative path is used then it will be resolved under the root directory.
|
||||||
|
page404 = "./404.html"
|
||||||
|
|
||||||
|
#### Page fallback for 404s
|
||||||
|
page-fallback = "./200.html"
|
||||||
Loading…
Reference in a new issue