Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config docker #1

Merged
merged 3 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading