This is a Rust-based Project Management System API built using the Actix-web framework. It provides endpoints for user registration and login.
- User Registration
- User Login
Returns a welcome message for the Project Management API.
Authenticates a user.
- Request Body:
email
: The user's email address.password
: The user's password.
- Response:
token
: A JSON Web Token (JWT) that can be used to authenticate the user.
Registers a new user.
- Request Body:
name
: The user's name.email
: The user's email address.password
: The user's password.
- Response:
message
: A success message indicating that the user has been registered.
The project is structured as follows:
- src/main.rs: The main entry point of the application.
Cargo.toml
: The project's configuration file.Dockerfile
: The Dockerfile used to build the project's Docker image.
To clone the repository, run the following command:
git clone https://github.com/your-username/project-management.git
Replace your-username
with your actual GitHub username.
To fork the repository, follow these steps:
- Log in to your GitHub account.
- Navigate to the repository's page.
- Click the "Fork" button in the top-right corner of the page.
- Choose the account where you want to fork the repository.
- Click "Create fork" to create a new fork of the repository.
To build the Docker image, run the following command:
docker build -t project-management .
This will build the Docker image using the instructions in the Dockerfile
.
To run the Docker container, run the following command:
docker run -p 8080:8080 project-management
This will start a new container from the project-management
image and map port 8080 on the host machine to port 8080 in the container.
The Dockerfile is set up to create a multi-stage build for the Rust project. It uses rust:alpine
for the build stage and alpine:latest
for the run stage.
# NB: This is not a production-grade Dockerfile.
#################
## build stage ##
#################
FROM rust:alpine AS builder
WORKDIR /code
RUN apk add --no-cache gcc g++ musl-dev
# Download crates-io index and fetch dependency code.
# This step avoids needing to spend time on every build downloading the index
# which can take a long time within the docker context. Docker will cache it.
RUN USER=root cargo init
COPY Cargo.toml Cargo.toml
RUN cargo fetch
# copy app files
COPY src src
# compile app
RUN cargo build --release
###############
## run stage ##
###############
# FROM debian:buster-slim
FROM alpine:latest
WORKDIR /app
# copy server binary from build stage
COPY --from=builder /code/target/release/project-management project-management
# set user to non-root unless root is required for your app
USER 1001
# indicate what port the server is running on
EXPOSE 8080
# run server
CMD [ "/app/project-management" ]
This project is licensed under the MIT License. See the LICENSE file for more details.