Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker build #193

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Docker Build and Publish

on:
release:
types: [published]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Build stage
FROM node:20-alpine as build

WORKDIR /app
COPY package*.json ./
RUN npm ci

COPY . .
RUN npm run build

# Production stage
FROM nginx:alpine

# Copy built files
COPY --from=build /app/dist /usr/share/nginx/html/web

# Configure nginx to handle SPA routing
RUN echo 'server { \
listen 80; \
location /web { \
alias /usr/share/nginx/html/web; \
try_files $uri $uri/ /web/index.html; \
} \
location / { \
return 301 /web; \
} \
}' > /etc/nginx/conf.d/default.conf

EXPOSE 80
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@

Welcome to the next generation of the TeddyCloud Administration Frontend!

## Docker Deployment

You can run the application in a Docker container. The container is optimized for production use and uses nginx to serve the static files.

### Building the Docker Image

Build the Docker image:
```bash
docker build -t teddycloud-web:latest .
```

### Running the Container

The container serves static files at the /web path. All application configuration (API URL, web base path, etc.) should be configured in your runtime environment where the application is accessed.

Run the container exposing port 80:
```bash
docker run -d -p 80:80 teddycloud-web:latest
```

The application will be available at http://localhost/web


If you are using this repository for the first time, please refer to the **General React Information** section first.

## TeddyCloud configuration
Expand Down