This project is a Go-based server for managing a movie database, utilizing PostgreSQL as the database engine. The server includes features such as rate limiting, security headers, email verification, performance metrics, and a graceful shutdown process for enhanced stability and security. It also includes deployment scripts for production using Caddy and Azure.
Before running the commands in this Makefile, ensure that you have the following:
- Go installed
- PostgreSQL installed and running
migrate
tool installed for database migrations- SSH access to the production server
.envrc
file with necessary environment variables
make run/api
Runs the cmd/api
application using the database credentials specified in the .envrc
file.
make db/psql
Connects to the PostgreSQL database using psql
with the DSN defined in the .envrc
file.
make db/migration/new name=<migration_name>
Creates a new SQL migration file in the migration
directory.
make db/migration/up
Applies all up migrations to the PostgreSQL database. Confirmation is required.
make audit
Formats the code, vets it, and runs tests for the project, including running staticcheck
.
make vendor
Tidies and verifies Go module dependencies, then vendors them for the project.
make build/api
Builds the API for both the local environment and Linux (amd64), including versioning information from Git.
make production/connect
SSH into the production server using the specified production IP.
make production/deploy/api
Deploys the API and runs database migrations on the production server.
make production/configure/api.service
Uploads and configures the api.service
file for systemd on the production server.
make production/configure/caddyfile
Uploads and configures the Caddyfile for the reverse proxy on the production server.
- Ensure the
.envrc
file contains the necessary environment variables likeCINLIM_DB_DSN
. - The production IP (
20.244.47.212
) is a placeholder and should be updated with the actual IP for your deployment environment.