diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..83f0504 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +node_modules +dist +.git +.github +.vscode +.idea +coverage +*.log +.env +.env.* +!.env.example +Dockerfile +.dockerignore diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..d59d12f --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,54 @@ +name: Docker Image + +on: + push: + branches: [main] + release: + types: [published] + +jobs: + build: + name: Build & Push + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository_owner }}/ui + tags: | + type=sha,format=short,enable=${{ github.event_name == 'push' }} + type=semver,pattern={{version}},enable=${{ github.event_name == 'release' }} + type=semver,pattern={{major}}.{{minor}},enable=${{ github.event_name == 'release' }} + type=raw,value=latest,enable=${{ github.event_name == 'release' && !github.event.release.prerelease }} + labels: | + org.opencontainers.image.title=FlatRun UI + org.opencontainers.image.description=Web interface for FlatRun container orchestration + org.opencontainers.image.vendor=FlatRun + org.opencontainers.image.licenses=MIT + org.opencontainers.image.documentation=https://github.com/${{ github.repository }}#readme + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9c8e5ee --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# syntax=docker/dockerfile:1 + +FROM node:22-alpine AS build +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm ci +COPY . . +RUN npm run build + +FROM nginx:alpine + +LABEL org.opencontainers.image.title="FlatRun UI" \ + org.opencontainers.image.description="Web interface for FlatRun container orchestration" \ + org.opencontainers.image.vendor="FlatRun" \ + org.opencontainers.image.licenses="MIT" \ + org.opencontainers.image.source="https://github.com/flatrun/ui" \ + org.opencontainers.image.url="https://github.com/flatrun/ui" \ + org.opencontainers.image.documentation="https://github.com/flatrun/ui#readme" + +COPY --from=build /app/dist /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..5c5f7f1 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,20 @@ +server { + listen 80 default_server; + listen [::]:80 default_server; + server_name _; + + root /usr/share/nginx/html; + index index.html; + + client_max_body_size 100M; + + location / { + try_files $uri $uri/ /index.html; + add_header Cache-Control "no-cache"; + } + + location /assets/ { + expires 30d; + add_header Cache-Control "public"; + } +}