Skip to content

Commit 7ea40bf

Browse files
committed
feat: Add Dockerfile and GitHub Actions workflow for ResourceHub deployment
1 parent 564a3d9 commit 7ea40bf

2 files changed

Lines changed: 91 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Deploy ResourceHub
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build-and-deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
16+
- name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@v3
18+
19+
- name: Log in to DockerHub
20+
uses: docker/login-action@v3
21+
with:
22+
username: ${{ secrets.DOCKERHUB_USERNAME }}
23+
password: ${{ secrets.DOCKERHUB_TOKEN }}
24+
25+
- name: Build and push Docker image
26+
uses: docker/build-push-action@v5
27+
with:
28+
context: .
29+
push: true
30+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/resourcehub:latest
31+
# No build-args for secrets; secrets will be injected at runtime
32+
33+
# Add deployment steps
34+
- name: Deploy container
35+
env:
36+
USER: ${{ secrets.USER }}
37+
PASSWORD: ${{ secrets.PASSWORD }}
38+
HOST: ${{ secrets.HOST }}
39+
PORT: ${{ secrets.PORT }}
40+
DATABASE: ${{ secrets.DATABASE }}
41+
SMTP_HOST: ${{ secrets.SMTP_HOST }}
42+
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
43+
SMTP_USER: ${{ secrets.SMTP_USER }}
44+
PDFSHIFT_API_KEY: ${{ secrets.PDFSHIFT_API_KEY }}
45+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
46+
run: |
47+
docker run -d \
48+
-e USER="$USER" \
49+
-e PASSWORD="$PASSWORD" \
50+
-e HOST="$HOST" \
51+
-e PORT="$PORT" \
52+
-e DATABASE="$DATABASE" \
53+
-e SMTP_HOST="$SMTP_HOST" \
54+
-e SMTP_PASSWORD="$SMTP_PASSWORD" \
55+
-e SMTP_USER="$SMTP_USER" \
56+
-e PDFSHIFT_API_KEY="$PDFSHIFT_API_KEY" \
57+
-p 80:80 -p 9090-9094:9090-9094 \
58+
"$DOCKERHUB_USERNAME/resourcehub:latest"

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Dockerfile for ResourceHub
2+
FROM ubuntu:22.04
3+
4+
# Update OS packages and install system dependencies
5+
RUN apt-get update && apt-get install -y \
6+
curl \
7+
unzip \
8+
nodejs \
9+
npm \
10+
openjdk-11-jre
11+
12+
# Download and extract Ballerina SDK
13+
RUN curl -L https://github.com/ballerina-platform/ballerina-lang/releases/download/v2201.12.7/ballerina-2201.12.7-swan-lake.zip -o ballerina.zip && \
14+
unzip ballerina.zip -d /opt/ballerina && \
15+
rm ballerina.zip
16+
ENV PATH="/opt/ballerina/bin:${PATH}"
17+
18+
# Build the backend
19+
WORKDIR /app/Back-End
20+
COPY Back-End /app/Back-End
21+
RUN bal build
22+
23+
# Build the frontend
24+
WORKDIR /app/Front-End
25+
COPY Front-End /app/Front-End
26+
RUN npm install && npm run build
27+
28+
# Port configuration
29+
EXPOSE 9090 9091 9092 9093 9094 80
30+
31+
# Prepare the final image
32+
WORKDIR /app
33+
CMD ["sh", "-c", "java -jar /app/Back-End/target/bin/ResourceHub.jar & npx serve -s /app/Front-End/build -l 80"]

0 commit comments

Comments
 (0)