This is a simple URL shortener application built with Go and Docker. App can be run locally or in Docker.
- Go
- Docker
- Postgres
- used schema is
urlshortener
- table
keys
is created automatically
- used schema is
- [opt] Make (for running Makefile)
- [opt] Bruno (for endpoint tests)
- Create a new file
.env
in the root directory of the project - Add the following environment variables to the file:
DSN=host=192.168.88.221 port=5432 user=postgres password=SECRET sslmode=disable timezone=UTC connect_timeout=5 search_path=uslshortener
PORT=80
DOMAIN=localhost
PROTOCOL=http
- Clone the repository
git clone https://github.com/kamildemocko/URLShortener.git
- Create network and make sure DB server has access to the same network
docker network url-shortener-net
- Build the Docker image
docker-compose build
- Run the Docker container
docker-compose up -d
- Clone the repository
git clone https://github.com/kamildemocko/URLShortener.git
- Download dependencies
go mod download
- Run
make start
- Open your web browser and navigate to
http://localhost:PORT/short
(where PORT is port that is set up in .env file or docker-compose.yaml) - Enter a custom short link key and a long URL
- Click on "Get short link"
- Your short link will be displayed
- Click on "Copy to Clipboard" to copy the short link