Here you will understand how to run and setup the development environment for twitterclone
NOTE: To run this app locally you need to have an AWS S3 Bucket available so that uploading images will work. (Might add Cloudinary and on-disk implementation in the future)
Prerequisites
Create .env file in configs/
directory by copying configs/.env.example
and setup the environment variables
- Running the containers with
docker-compose up -d
- To stop the containers
docker-compose stop
Prerequisites
Install PostgreSQL:
Create a database named twitterclone
$ psql
postgres=# CREATE DATABASE twitterclone;
Install golang-migrate here
Run the migrations.
$ ./scripts/run_migrations.sh Your_PostgreSQL_URL
# Example PostgreSQL url: postgres://postgres:[email protected]:5432/twitterclone\?sslmode=disable
Install Redis:
Install Golang:
Navigate to /configs
and set the following environment variables:
APP_NAME=twitter-clone
APP_HOST=127.0.0.1
APP_PORT=5000
APP_DOMAIN=localhost
DEBUG=false
ACCESS_TOKEN_SECRET=
REFRESH_TOKEN_SECRET=
# Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h"
# 15m -> 15 minutes
ACCESS_TOKEN_DURATION=15m
# 168h -> 7 days
REFRESH_TOKEN_DURATION=168h
DEFAULT_AVATAR_URL=
# 2.5 mb in bytes
MAX_UPLOAD_SIZE=2621440
# For attaching images in tweets
# 32 mb in bytes
MAX_TWEET_ATTACHMENT_SIZE=33554432
DB_USER=postgres
DB_PASSWORD=
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=twitterclone
REDIS_ADDR=127.0.0.1:6379
REDIS_PASSWORD=
REDIS_KEY_DELIMITER=::
AWS_REGION=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_S3_BUCKET_NAME=
# [Optional] can leave empty here
AWS_SESSION_TOKEN=
Running the server
$ go run cmd/rest/main.go --prefork
# Using hot-reloading (Optional must have air installed)
$ make dev
Navigate to /web
- Run
yarn
to install the dependencies - Run
yarn dev
to run the frontend