Skip to content

Commit a49c7e5

Browse files
authored
Merge pull request #59 from flatrun/ci/docker-image
feat(ci): Publish UI as lightweight container image
2 parents 158b27b + e6f0ebf commit a49c7e5

4 files changed

Lines changed: 109 additions & 0 deletions

File tree

.dockerignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
node_modules
2+
dist
3+
.git
4+
.github
5+
.vscode
6+
.idea
7+
coverage
8+
*.log
9+
.env
10+
.env.*
11+
!.env.example
12+
Dockerfile
13+
.dockerignore

.github/workflows/docker-image.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Docker Image
2+
3+
on:
4+
push:
5+
branches: [main]
6+
release:
7+
types: [published]
8+
9+
jobs:
10+
build:
11+
name: Build & Push
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v3
21+
22+
- name: Log in to GitHub Container Registry
23+
uses: docker/login-action@v3
24+
with:
25+
registry: ghcr.io
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Extract metadata
30+
id: meta
31+
uses: docker/metadata-action@v5
32+
with:
33+
images: ghcr.io/${{ github.repository_owner }}/ui
34+
tags: |
35+
type=sha,format=short,enable=${{ github.event_name == 'push' }}
36+
type=semver,pattern={{version}},enable=${{ github.event_name == 'release' }}
37+
type=semver,pattern={{major}}.{{minor}},enable=${{ github.event_name == 'release' }}
38+
type=raw,value=latest,enable=${{ github.event_name == 'release' && !github.event.release.prerelease }}
39+
labels: |
40+
org.opencontainers.image.title=FlatRun UI
41+
org.opencontainers.image.description=Web interface for FlatRun container orchestration
42+
org.opencontainers.image.vendor=FlatRun
43+
org.opencontainers.image.licenses=MIT
44+
org.opencontainers.image.documentation=https://github.com/${{ github.repository }}#readme
45+
46+
- name: Build and push
47+
uses: docker/build-push-action@v5
48+
with:
49+
context: .
50+
push: true
51+
tags: ${{ steps.meta.outputs.tags }}
52+
labels: ${{ steps.meta.outputs.labels }}
53+
cache-from: type=gha
54+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM node:22-alpine AS build
4+
WORKDIR /app
5+
COPY package.json package-lock.json ./
6+
RUN npm ci
7+
COPY . .
8+
RUN npm run build
9+
10+
FROM nginx:alpine
11+
12+
LABEL org.opencontainers.image.title="FlatRun UI" \
13+
org.opencontainers.image.description="Web interface for FlatRun container orchestration" \
14+
org.opencontainers.image.vendor="FlatRun" \
15+
org.opencontainers.image.licenses="MIT" \
16+
org.opencontainers.image.source="https://github.com/flatrun/ui" \
17+
org.opencontainers.image.url="https://github.com/flatrun/ui" \
18+
org.opencontainers.image.documentation="https://github.com/flatrun/ui#readme"
19+
20+
COPY --from=build /app/dist /usr/share/nginx/html
21+
COPY nginx.conf /etc/nginx/conf.d/default.conf
22+
EXPOSE 80

nginx.conf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
server {
2+
listen 80 default_server;
3+
listen [::]:80 default_server;
4+
server_name _;
5+
6+
root /usr/share/nginx/html;
7+
index index.html;
8+
9+
client_max_body_size 100M;
10+
11+
location / {
12+
try_files $uri $uri/ /index.html;
13+
add_header Cache-Control "no-cache";
14+
}
15+
16+
location /assets/ {
17+
expires 30d;
18+
add_header Cache-Control "public";
19+
}
20+
}

0 commit comments

Comments
 (0)