Skip to content

Commit e0125b6

Browse files
authored
Config docker (#1)
* Config docker * Update workflow folder * Update readme to include some useful badegs
1 parent f521238 commit e0125b6

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed
File renamed without changes.

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Use an official Python runtime as a parent image
2+
FROM python:3.9-slim
3+
4+
# Set the working directory in the container
5+
WORKDIR /app
6+
7+
# Copy the requirements.txt file and install dependencies
8+
COPY requirements.txt .
9+
RUN pip install --no-cache-dir -r requirements.txt
10+
11+
# Copy the current directory contents into the container
12+
COPY . .
13+
14+
# Expose the port that FastAPI runs on (default: 8000)
15+
EXPOSE 8000
16+
17+
# Run the FastAPI app with Uvicorn server
18+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

README.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# SwiftComp-API
2+
[![Version](https://img.shields.io/github/v/release/wenbinyugroup/swiftcomp-api)](https://github.com/wenbinyu/swiftcomp-api/releases)
3+
[![Build Status](https://github.com/wenbinyugroup/swiftcomp-api/actions/workflows/ci.yml/badge.svg)](https://github.com/wenbinyugroup/swiftcomp-api/actions)
4+
[![codecov](https://codecov.io/gh/wenbinyugroup/swiftcomp-api/branch/main/graph/badge.svg)](https://codecov.io/gh/wenbinyugroup/swiftcomp-api)
5+
[![Last Commit](https://img.shields.io/github/last-commit/wenbinyugroup/swiftcomp-api)](https://github.com/wenbinyugroup/swiftcomp-api/commits/main)
6+
27

38
**SwiftComp-API** is a FastAPI-based backend designed to perform calculations related to composite laminate materials. It exposes various endpoints for computing engineering constants, plate properties, 3D laminate properties, and more. This API is suitable for researchers, engineers, and developers working in composite materials and structural analysis.
49

@@ -34,7 +39,53 @@
3439

3540
---
3641

37-
## Installation
42+
## Installation Using Docker (recommend)
43+
44+
### Prerequisites
45+
- Docker
46+
47+
### Step-by-Step Guide
48+
49+
1. **Clone the repository**:
50+
```bash
51+
git clone https://github.com/wenbinyugroup/swiftcomp-api.git
52+
cd swiftcomp-api
53+
```
54+
2. **Building the Docker Image**:
55+
You can build a Docker image for the FastAPI app using the following command:
56+
57+
```bash
58+
docker build -t swiftcomp-api .
59+
```
60+
3. **Running the Docker Container**:
61+
Once the image is built, you can run the application in a Docker container:
62+
63+
```bash
64+
docker run -d -p 8000:8000 swiftcomp-api
65+
```
66+
This will run the SwiftComp API app in a container and map port 8000 from the container to your local machine. You can access the application at http://localhost:8000.
67+
68+
4. **Running Tests Inside the Docker Container**:
69+
To run the tests inside the running Docker container:
70+
71+
```bash
72+
docker exec $(docker ps -q -f ancestor=swiftcomp-api) bash -c "PYTHONPATH=./ pytest"
73+
```
74+
This command sets the `PYTHONPATH` and runs `pytest` inside the running Docker container.
75+
76+
5. **Monitoring Logs**:
77+
To monitor the logs from the running Docker container in real time:
78+
79+
```bash
80+
docker logs -f <container_id_or_name>
81+
```
82+
You can get the container ID or name by running:
83+
84+
```bash
85+
docker ps
86+
```
87+
88+
## Installation Locally
3889

3990
To set up the project locally, follow these steps:
4091

0 commit comments

Comments
 (0)