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.git
Change directory:
cd url-shortener-nginx
Build the image using the following command:
docker build ./nginx -t nginx:latest
Run 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 nginx
Arguments:
-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.internal
with the IP address of the web server.--env WEB_SERVER_PORT=26802
- The port of the web server. You can replace26802
with the port of the web server.--name container-name
- The name of the container. You can replacecontainer-name
with any name you want.
Run the container using the following command:
docker-compose up -d
To rebuild the container, use the following command:
docker-compose up -d --build
Edit 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.git
Change directory:
cd url-shortener-nginx
Create a virtual environment:
python -m venv venv
Activate the virtual environment:
-
On Windows:
.\venv\Scripts\activate
-
On Linux and macOS:
source venv/bin/activate
Install Poetry:
pip install poetry
Install dependencies:
poetry install --only main --no-root
Run the tests using the following command:
pytest
Note
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.