Skip to content

Commit 401eebe

Browse files
authored
Merge pull request #6 from sebasruii/develop
feat: Add docker deploy
2 parents 2432fa4 + 9eebd86 commit 401eebe

13 files changed

+190
-25
lines changed

.github/workflows/docker-image.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Docker Image CI/CD
2+
3+
# Trigger the workflow when a tag is pushed
4+
on:
5+
push:
6+
tags:
7+
- "v*" # Matches any version tag that starts with "v" (e.g., v1.0.0)
8+
9+
jobs:
10+
build-and-publish:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
# Step 1: Checkout the repository
15+
- name: Checkout the code
16+
uses: actions/checkout@v3
17+
18+
# Step 2: Build the Docker image
19+
- name: Build the Docker image
20+
run: docker build . --file Dockerfile --tag frabenrui/flamapy-ide:${{ github.ref_name }}
21+
22+
# Step 3: Login to DockerHub
23+
- name: Log in to DockerHub
24+
uses: docker/login-action@v3
25+
with:
26+
username: ${{ secrets.DOCKERHUB_USERNAME }}
27+
password: ${{ secrets.DOCKERHUB_API_TOKEN }}
28+
29+
# Step 4: Push the Docker image to DockerHub
30+
- name: Push the Docker image
31+
run: docker push frabenrui/flamapy-ide:${{ github.ref_name }}
32+
33+
# Optional: Step 5: Push the "latest" tag (for production deployments)
34+
- name: Tag as latest
35+
if: startsWith(github.ref, 'refs/tags/')
36+
run: |
37+
docker tag frabenrui/flamapy-ide:${{ github.ref_name }} frabenrui/flamapy-ide:latest
38+
docker push frabenrui/flamapy-ide:latest

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,3 @@ dist-ssr
2222
*.njsproj
2323
*.sln
2424
*.sw?
25-
26-
27-
public/pyodide/*.whl

Dockerfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Stage 1: Base Image
2+
FROM node:18 AS base
3+
4+
# Set working directory
5+
WORKDIR /app
6+
7+
# Copy package.json and package-lock.json for installation
8+
COPY package*.json ./
9+
10+
# Install dependencies
11+
RUN npm install
12+
13+
# Copy the rest of the app
14+
COPY . .
15+
16+
# Stage 2: Development
17+
FROM base AS dev
18+
19+
# Set environment to development
20+
ENV NODE_ENV=development
21+
22+
# Expose Vite default port
23+
EXPOSE 5173
24+
25+
# Start the Vite development server
26+
CMD ["npm", "run", "dev", "--", "--host"]
27+
28+
# Stage 3: Production Build
29+
FROM base AS build
30+
31+
# Set environment to production
32+
ENV NODE_ENV=production
33+
34+
# Build the app
35+
RUN npm run build
36+
37+
# Stage 4: Production - Nginx for serving static files
38+
FROM nginx:alpine AS prod
39+
40+
# Set environment to production
41+
ENV NODE_ENV=production
42+
43+
# Copy built files from the build stage
44+
COPY --from=build /app/dist /usr/share/nginx/html
45+
46+
# Copy custom Nginx configuration, if needed (optional)
47+
COPY nginx.conf /etc/nginx/nginx.conf
48+
49+
# Expose port 80 for the Nginx server
50+
EXPOSE 80
51+
52+
# Start Nginx
53+
CMD ["nginx", "-g", "daemon off;"]

README.md

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,75 @@ FlamapyIDE is Francisco Benítez's (@sebasruii) Final Degree Project. It consist
1717
- Different export options, including Glencoe, FeatureIDE, AFM or SPLOT
1818
- Import feature models defined in different formats into UVL, including Glencoe, FeatureIDE or AFM
1919

20-
## Getting started
20+
# Deploying the Project locally
2121

22-
To run FlamapyIDE locally, you must have NodeJS (>=18.5) installed. Clone this repository and follow these steps:
22+
## Prerequisites
2323

24-
### 1. Install dependencies
24+
- To run FlamapyIDE locally, you must have NodeJS (>=18.5) installed.
25+
- Your browser must support WASM.
2526

26-
Navigate to the project root and run:
27-
`npm install`
27+
1. **Clone the repository** (if you haven't already):
2828

29-
### 2. Run pyodide setup script
29+
```bash
30+
git clone https://github.com/sebasruii/flamapy-ide.git
31+
cd flamapy-ide
3032

31-
Run:
32-
`node setup.mjs`
33-
This script will download all pyodide packages needed to install the provided Flamapy packages.
33+
```
3434

35-
### 3. Run FlamapyIDE
35+
2. **Install dependencies**
36+
37+
Run `npm install` and wait until all packages have been downloaded.
38+
39+
3. **Run FlamapyIDE**
3640

3741
Once packages have been downloaded, you can run:
3842
`npm run dev`
3943
and this will deploy FlamapyIDE on localhost.
44+
45+
# Deploying the Project Using Docker
46+
47+
## Prerequisites
48+
49+
Ensure you have Docker installed on your machine. You can install it from [Docker's official site](https://docs.docker.com/get-docker/).
50+
51+
---
52+
53+
## Building the Docker Image
54+
55+
1. **Clone the repository** (if you haven't already):
56+
57+
```bash
58+
git clone https://github.com/sebasruii/flamapy-ide.git
59+
cd flamapy-ide
60+
61+
```
62+
63+
1. **Build the Docker image**
64+
65+
- For production:
66+
```
67+
docker build -t flamapy-ide:prod --target prod .
68+
```
69+
- For development:
70+
```
71+
docker build -t flamapy-ide:dev --target dev .
72+
```
73+
74+
## Running the Docker Container
75+
76+
### Run the container using the production image:
77+
78+
```bash
79+
docker run -p 80:80 flamapy-ide:prod
80+
```
81+
82+
This starts the app on port 80 using Nginx. You can access the app at http://localhost.
83+
84+
Running in Development
85+
Run the container with the development image:
86+
87+
```bash
88+
docker run -p 5173:5173 -v $(pwd):/app -v /app/node_modules flamapy-ide:dev
89+
```
90+
91+
This starts the Vite development server with hot-reloading on port 5173. Access it at http://localhost:5173.

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
5+
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Vite + React</title>
7+
<title>FlamapyIDE</title>
88
</head>
99
<body>
1010
<div id="root"></div>

nginx.conf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# /etc/nginx/nginx.conf
2+
3+
events {
4+
worker_connections 1024;
5+
}
6+
7+
http {
8+
include /etc/nginx/mime.types;
9+
default_type application/octet-stream;
10+
11+
sendfile on;
12+
keepalive_timeout 65;
13+
14+
# Define the server block
15+
server {
16+
listen 80;
17+
server_name localhost;
18+
19+
# Root directory where the static files are served
20+
root /usr/share/nginx/html;
21+
22+
# Index file for the root
23+
index index.html;
24+
25+
# Handle requests for static assets
26+
location / {
27+
try_files $uri /index.html; # This serves index.html for any route
28+
}
29+
30+
# Optional: Gzip compression for better performance
31+
gzip on;
32+
gzip_types text/css application/javascript application/json image/svg+xml;
33+
gzip_min_length 1000;
34+
}
35+
}

public/favicon.ico

12.8 KB
Binary file not shown.
122 KB
Binary file not shown.
190 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)