Skip to content

Commit 3b596b7

Browse files
authored
Merge pull request #200 from oss-slu/add-dockerfiles-and-workflows
Add dockerfiles and workflows
2 parents fd0f365 + 29abd76 commit 3b596b7

5 files changed

Lines changed: 125 additions & 0 deletions

File tree

.github/workflows/backend.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build and Push Backend
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'Backend/**'
8+
- 'Dockerfile.backend'
9+
10+
env:
11+
IMAGE_NAME: ghcr.io/oss-slu/oss_dev_analytics/backend
12+
13+
jobs:
14+
build-and-push:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: docker/login-action@v3
23+
with:
24+
registry: ghcr.io
25+
username: ${{ github.actor }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- id: meta
29+
uses: docker/metadata-action@v5
30+
with:
31+
images: ${{ env.IMAGE_NAME }}
32+
tags: |
33+
type=sha,prefix=,format=short
34+
type=raw,value=latest,enable={{is_default_branch}}
35+
36+
- uses: docker/build-push-action@v5
37+
with:
38+
context: .
39+
file: Dockerfile.backend
40+
push: true
41+
tags: ${{ steps.meta.outputs.tags }}

.github/workflows/frontend.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build and Push Frontend
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'Frontend/**'
8+
- 'Dockerfile.frontend'
9+
- 'nginx.conf'
10+
11+
env:
12+
IMAGE_NAME: ghcr.io/oss-slu/oss_dev_analytics/frontend
13+
14+
jobs:
15+
build-and-push:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- uses: docker/login-action@v3
24+
with:
25+
registry: ghcr.io
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- id: meta
30+
uses: docker/metadata-action@v5
31+
with:
32+
images: ${{ env.IMAGE_NAME }}
33+
tags: |
34+
type=sha,prefix=,format=short
35+
type=raw,value=latest,enable={{is_default_branch}}
36+
37+
- uses: docker/build-push-action@v5
38+
with:
39+
context: .
40+
file: Dockerfile.frontend
41+
push: true
42+
tags: ${{ steps.meta.outputs.tags }}

Dockerfile.backend

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM python:3.11-slim
2+
3+
WORKDIR /app
4+
5+
COPY docs/requirements.txt ./requirements.txt
6+
RUN pip install --no-cache-dir -r requirements.txt
7+
8+
COPY Backend/ ./Backend/
9+
COPY data/ ./data/
10+
11+
ENV DATA_PATH=/data/sprint_data.json
12+
ENV OUTPUT_PATH=/data/health.json

Dockerfile.frontend

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM node:20-alpine AS builder
2+
3+
WORKDIR /app
4+
5+
COPY Frontend/package*.json ./
6+
RUN npm ci
7+
8+
COPY Frontend/ ./
9+
RUN npm run build
10+
11+
FROM nginx:alpine
12+
COPY --from=builder /app/dist /usr/share/nginx/html
13+
COPY nginx.conf /etc/nginx/conf.d/default.conf
14+
15+
EXPOSE 80

nginx.conf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
server {
2+
listen 80;
3+
server_name _;
4+
root /usr/share/nginx/html;
5+
index index.html;
6+
7+
location /data/ {
8+
alias /usr/share/nginx/html/data/;
9+
add_header Cache-Control "no-cache";
10+
}
11+
12+
location / {
13+
try_files $uri $uri/ /index.html;
14+
}
15+
}

0 commit comments

Comments
 (0)