Skip to content

Commit

Permalink
Config docker (#1)
Browse files Browse the repository at this point in the history
* Config docker

* Update workflow folder

* Update readme to include some useful badegs
  • Loading branch information
banghuazhao authored Sep 22, 2024
1 parent f521238 commit e0125b6
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
File renamed without changes.
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Use an official Python runtime as a parent image
FROM python:3.9-slim

# Set the working directory in the container
WORKDIR /app

# Copy the requirements.txt file and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy the current directory contents into the container
COPY . .

# Expose the port that FastAPI runs on (default: 8000)
EXPOSE 8000

# Run the FastAPI app with Uvicorn server
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
53 changes: 52 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# SwiftComp-API
[![Version](https://img.shields.io/github/v/release/wenbinyugroup/swiftcomp-api)](https://github.com/wenbinyu/swiftcomp-api/releases)
[![Build Status](https://github.com/wenbinyugroup/swiftcomp-api/actions/workflows/ci.yml/badge.svg)](https://github.com/wenbinyugroup/swiftcomp-api/actions)
[![codecov](https://codecov.io/gh/wenbinyugroup/swiftcomp-api/branch/main/graph/badge.svg)](https://codecov.io/gh/wenbinyugroup/swiftcomp-api)
[![Last Commit](https://img.shields.io/github/last-commit/wenbinyugroup/swiftcomp-api)](https://github.com/wenbinyugroup/swiftcomp-api/commits/main)


**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.

Expand Down Expand Up @@ -34,7 +39,53 @@

---

## Installation
## Installation Using Docker (recommend)

### Prerequisites
- Docker

### Step-by-Step Guide

1. **Clone the repository**:
```bash
git clone https://github.com/wenbinyugroup/swiftcomp-api.git
cd swiftcomp-api
```
2. **Building the Docker Image**:
You can build a Docker image for the FastAPI app using the following command:

```bash
docker build -t swiftcomp-api .
```
3. **Running the Docker Container**:
Once the image is built, you can run the application in a Docker container:

```bash
docker run -d -p 8000:8000 swiftcomp-api
```
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.

4. **Running Tests Inside the Docker Container**:
To run the tests inside the running Docker container:

```bash
docker exec $(docker ps -q -f ancestor=swiftcomp-api) bash -c "PYTHONPATH=./ pytest"
```
This command sets the `PYTHONPATH` and runs `pytest` inside the running Docker container.

5. **Monitoring Logs**:
To monitor the logs from the running Docker container in real time:

```bash
docker logs -f <container_id_or_name>
```
You can get the container ID or name by running:

```bash
docker ps
```

## Installation Locally

To set up the project locally, follow these steps:

Expand Down

0 comments on commit e0125b6

Please sign in to comment.