Warning
This repository is part of a larger project that consists of multiple repositories. Using this repository on its own is not recommended, as it may not function correctly without the other components of the project. For complete functionality and proper integration, please refer to the kramber1024/url-shortener.
- π Docker
Note
Please ensure that Docker is properly configured and running on your system.
Clone repository:
git clone https://github.com/kramber1024/url-shortener-nginx.gitChange directory:
cd url-shortener-nginxBuild the image using the following command:
docker build ./nginx -t nginx:latestRun the container using the following command:
docker run -d -p 80:80 -p 443:443 --env WEB_SERVER_HOST=host.docker.internal --env WEB_SERVER_PORT=26802 --name container-name nginxArguments:
-p 80:80 -p 443:443- Expose ports 80 and 443 to the host.--env WEB_SERVER_HOST=host.docker.internal- The host of the web server. You can replacehost.docker.internalwith the IP address of the web server.--env WEB_SERVER_PORT=26802- The port of the web server. You can replace26802with the port of the web server.--name container-name- The name of the container. You can replacecontainer-namewith any name you want.
Run the container using the following command:
docker-compose up -dTo rebuild the container, use the following command:
docker-compose up -d --buildEdit the compose.yaml file to change launch configuration.
name: docker-compose
services:
nginx:
container_name: nginx # Change the container name
build:
tags:
- nginx:latest
context: ./nginx
dockerfile: Dockerfile
ports: # Change the ports
- "80:80"
- "443:443"
environment: # Change the environment variables
- WEB_SERVER_HOST=host.docker.internal
- WEB_SERVER_PORT=26802- π Docker
- π Python 3.12
Clone repository:
git clone https://github.com/kramber1024/url-shortener-nginx.gitChange directory:
cd url-shortener-nginxCreate a virtual environment:
python -m venv venvActivate the virtual environment:
-
On Windows:
.\venv\Scripts\activate
-
On Linux and macOS:
source venv/bin/activate
Install Poetry:
pip install poetryInstall dependencies:
poetry install --only main --no-rootRun the tests using the following command:
pytestNote
Make sure that Docker is running before running the tests.
======================== test session starts ========================
platform win32 -- Python 3.12.2, pytest-8.2.2, pluggy-1.5.0
rootdir: C:\Users\UserName\url-shortener-nginx
configfile: pyproject.toml
collected 2 items
tests\test_build.py . [ 50%]
tests\test_run.py . [100%]
=================== 2 passed in 66.27s (0:01:06) ====================This project is licensed under the terms of the MIT license.