Skip to content

Commit 2225c86

Browse files
feat: docker (#18)
1 parent b7fdff1 commit 2225c86

File tree

4 files changed

+136
-0
lines changed

4 files changed

+136
-0
lines changed

.devops/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# ------------------------------------------------------------------
2+
# Stage 1 – Build the React application
3+
# ------------------------------------------------------------------
4+
# Use the official Node image (alpine for a small footprint)
5+
FROM node:18-alpine AS build
6+
7+
# Create /app directory in the container
8+
WORKDIR /app
9+
10+
# Copy package.json & package-lock.json (or yarn.lock) first
11+
# so Docker can cache the npm install step.
12+
COPY package*.json ./
13+
14+
# Install dependencies (npm ci is deterministic and fast)
15+
RUN npm ci --silent
16+
17+
# Copy the rest of the source code
18+
COPY . .
19+
20+
# Build the React app – creates ./build directory
21+
RUN npm run build
22+
23+
# ------------------------------------------------------------------
24+
# Stage 2 – Serve the build with nginx
25+
# ------------------------------------------------------------------
26+
FROM nginx:alpine as webui
27+
28+
# Copy the build folder from the previous stage
29+
COPY --from=build /app/dist /usr/share/nginx/html
30+
31+
# Copy custom nginx config
32+
# COPY nginx.conf /etc/nginx/conf.d/default.conf
33+
34+
# Expose port 80 – the default HTTP port
35+
EXPOSE 80
36+
37+
# Start nginx in the foreground
38+
CMD ["nginx", "-g", "daemon off;"]

.dockerignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
### JetBrains ###
2+
.idea
3+
4+
### VisualStudioCode ###
5+
.vscode
6+
7+
### macOS ###
8+
.DS_Store
9+
10+
### Windows ###
11+
Thumbs.db
12+
13+
### Node ###
14+
node_modules
15+
npm-debug.log
16+
*.log
17+
18+
### Docker ###
19+
Dockerfile
20+
.dockerignore
21+
22+
### Git ###
23+
.git
24+
.gitignore
25+
26+
# Others
27+
*.md

.github/workflows/docker.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
workflow_dispatch:
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
telegram-build-and-publish:
16+
runs-on: ubuntu-latest
17+
18+
permissions:
19+
contents: read
20+
packages: write
21+
attestations: write
22+
id-token: write
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
# Set up BuildKit Docker container builder to be able to build
29+
# multi-platform images and export cache
30+
# https://github.com/docker/setup-buildx-action
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
# Login against a Docker registry except on PR
35+
# https://github.com/docker/login-action
36+
- name: Log into registry ${{ env.REGISTRY }}
37+
if: github.event_name != 'pull_request'
38+
uses: docker/login-action@v3
39+
with:
40+
registry: ${{ env.REGISTRY }}
41+
username: ${{ github.actor }}
42+
password: ${{ secrets.GITHUB_TOKEN }}
43+
44+
# Extract metadata (tags, labels) for Docker
45+
# https://github.com/docker/metadata-action
46+
- name: Extract Docker metadata
47+
id: meta
48+
uses: docker/metadata-action@v5
49+
with:
50+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
51+
52+
# Build and push Docker image with Buildx (don't push on PR)
53+
# https://github.com/docker/build-push-action
54+
- name: Build and push Docker image
55+
id: build-and-push
56+
uses: docker/build-push-action@v5
57+
with:
58+
context: .
59+
file: .devops/Dockerfile
60+
platforms: linux/amd64,linux/arm64
61+
push: true
62+
tags: ${{ steps.meta.outputs.tags }}
63+
labels: ${{ steps.meta.outputs.labels }}

docker-compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
services:
2+
llama-ui:
3+
image: ghcr.io/olegshulyakov/llama.ui:latest
4+
container_name: llama-ui
5+
mem_limit: 64m
6+
restart: unless-stopped
7+
ports:
8+
- '80:80'

0 commit comments

Comments
 (0)