Shorty is a full-stack URL shortener app built with Node.js, Express, and MongoDB.
The backend also serves the frontend, so once the build is done — everything runs together in one container.
Before you begin, make sure you have the following installed:
git clone https://github.com/<your-username>/shorty.git
cd shortyYour repository includes an env.example file.
Create a new .env file based on it:
cp env.example .envThen open .env and fill in the required values:
PORT=3000
NODE_ENV=development
MONGODB_URL=mongodb+srv://<your-cluster-url>
BASE_URL=https://shorty.yourdomain.comThe frontend is located in the client folder and is served by the backend after building.
cd client
npm install
npm run build
cd ..Make sure you’re back in the project root directory.
podman build -t shorty:latest .Run the app with your environment variables.
podman run -d -p 3000:3000 -e PORT=3000 -e NODE_ENV=development -e MONGODB_URL="your-mongodb-url" -e BASE_URL="https://shorty.yourdomain.com" --name shorty-container localhost/shorty:latest✅ The app should now be running on:
http://localhost:3000
podman stop shorty-containerpodman start shorty-containerpodman logs -f shorty-containerpodman rm -f shorty-container
podman rmi shorty:latest- The frontend build output (
client/build) is automatically served by the backend Express server. .dockerignoreensures.envand unnecessary files are not included in the image.- MongoDB should be hosted externally (e.g., Atlas), as the container does not include a database.
If you’ve pushed your image to Docker Hub or Podman registry, others can directly pull and run:
podman pull docker.io/sanskarspamz/shorty:latest
podman run -d -p 3000:3000 --name shorty docker.io/sanskarspamz/shorty:latestYou can also add environment variables in the run command as shown above.
If you’d like to contribute to Shorty, follow these steps:
git fork https://github.com/<your-username>/shorty.git
git clone https://github.com/<your-username>/shorty.git
cd shortygit checkout -b feature/your-feature-nameBuild and test locally:
cd client
npm install && npm run build
cd ..
podman build -t shorty:test .
podman run -p 3000:3000 --env-file .env shorty:testgit add .
git commit -m "Added new feature"
git push origin feature/your-feature-nameGo to your fork on GitHub and create a pull request to the main repo.
- If you get “connection refused” on MongoDB, ensure your cluster’s IP whitelist includes
0.0.0.0/0. - If
localhost:3000doesn’t load, check container logs usingpodman logs shorty-container. - Always rebuild (
podman build ...) if you make code changes insrc/orclient/.
Sanskar Diwedi
📧 Contact
🌐 https://sanskardiwedi.in