This document provides step-by-step instructions for setting up and running Go Exam, a Go-based HTTP server for handling file uploads and saving image metadata to a PostgreSQL database.
Before you begin, ensure you have the following:
- Docker and Docker Compose installed on your system.
- Basic familiarity with Docker and using the command line.
-
Open your terminal.
-
Navigate to the directory where you want to clone the repository.
-
Run the following command to clone the repository:
shCopy code
git clone github.com/einnar82/go-exam
-
Navigate to the project's
config
folder. -
Open the
config.go
file. -
Update the following configuration values according to your preferences:
AuthToken
: Set the authorization token for the file uploads.StorageFolderPath
: Set the path to the storage folder within the project.DBConnectionString
: Set the PostgreSQL database connection string.
-
In your terminal, navigate to the root directory of the cloned repository.
-
Run the following command to start the application and PostgreSQL database:
shCopy code
docker-compose up -d
This will launch the application and expose it on port 8080.
- In your terminal, Run
go run main.go
- Open your web browser.
- Visit
http://localhost:8080
to access the file upload form.
- Open your web browser.
- Visit
http://localhost:5050
. - Log in using the default email (
admin@example.com
) and password (admin
). - Add a new server connection:
- Host:
postgres
- Port:
5432
- Database name, username, and password as specified in the
docker-compose.yml
file.
- Host:
- On the file upload form (
http://localhost:8080
), select an image file and provide the authorization token. - Click the "Upload" button.
- The image file will be saved in the storage folder, and its metadata will be stored in the PostgreSQL database.
When you're done testing the application, you can clean up:
-
In the terminal, navigate to the directory containing the
docker-compose.yml
file. -
Run the following command to stop and remove the containers:
shCopy code
docker-compose down
Congratulations! You've successfully set up and run Go Exam. Feel free to explore the uploaded files and metadata using the provided web interface and pgAdmin.