Warning
CSGHub
Portal has migrated the web framework from Rails to Gin. If you were previously using the Rails, please refer to the latest documentation to see how to migrate to the Gin.
This project is based on Rails, Vue3, Tailwind CSS, Administrate, Postgresql, Apache Arrow, DuckDB and GoGin. We appreciate the support and contributions from these open-source projects!
-
Visit the Go official download page.
-
Download the Go installation package suitable for your operating system.
-
Follow the Go installation guide to set it up.
-
Verify that you've installed Go by opening a command prompt and typing the following command:
go version
Confirm that the command prints the installed version of Go.
-
Visit the Node.js official website.
-
Download and install the LTS (Long Term Support) version suitable for your operating system.
-
Verify that you've installed Node.js by opening a command prompt and typing the following command:
node --version npm --version
-
Install Yarn:
npm install -g yarn
-
Verify Yarn installation:
yarn --version
-
Select a directory to serve as your Go workspace (e.g.,
~/go
). -
Add the following to your shell configuration file (e.g.,
.bashrc
or.zshrc
) to setGOPATH
.export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin
-
Run one of the following commands to ensure the configuration file updates take effect.
source ~/.bashrc # or source ~/.zshrc
-
Run the following command to verify that
GOPATH
is correctly set.go env GOPATH
Confirm that the command prints your workspace directory, e.g.,
/home/username/go
.
-
Follow the direnv official documentation for installation.
-
Add the following to your shell config file (e.g.,
.bashrc
,.zshrc
, etc.) to configure direnv.eval "$(direnv hook bash)" # if using bash # or eval "$(direnv hook zsh)" # if using zsh
Reload your shell configuration file or restart your terminal.
-
In the project root directory, run the following command to create
.envrc
file.cp .envrc.example .envrc
-
Edit the
.envrc
file as needed and set necessary environment variables. For example:export CSGHUB_PORTAL_S3_ACCESS_KEY_ID=xxx export CSGHUB_PORTAL_S3_ACCESS_KEY_SECRET=yyy # Add other required environment variables
-
In the project root directory, run the following command to allow direnv to load
.envrc
file.direnv allow .
Install the necessary Go modules by running:
go mod tidy
Air is a tool that allows live reloading of Go applications. Install it by running:
go install github.com/air-verse/air@latest
Navigate to the frontend
directory and install dependencies using Yarn:
cd frontend
yarn install
-
Create a new database in your database system (PostgreSQL recommended):
CREATE DATABASE your_database_name;
Replace
your_database_name
with the actual database name you want to use. -
Update your
.envrc
file with the correct database connection information. -
Run the following command to initialize the database:
go run cmd/csghub-portal/main.go migration init
-
Run the following command to perform database migration:
go run cmd/csghub-portal/main.go migration migrate
To start both frontend and backend services simultaneously, run the following command:
make
To start only the frontend service, run the following command:
make run-frontend
To start only the Go service, run the following command:
make run-backend
-
Create
.env
file:- In the project root directory, locate the
.env.example
file. - Copy
.env.example
and rename the copy to.env
. - Open the
.env
file and configure the necessary environment variables for your environment.
cp .env.example .env
- In the project root directory, locate the
-
Edit .env file:
- Open the
.env
file with a text editor. - Modify each configuration item based on your development environment and requirements.
- Ensure all necessary environment variables are set correctly.
- Open the
-
In VS Code, open the "Run and Debug" view (typically the play button icon in the sidebar).
-
In the top dropdown menu, you can select one of the following configurations:
- "portal": Start the main server
- "init": Initialize the database
- "migrate": Run database migration
- "rollback": Rollback the database migration
-
Build the project:
make build
-
Run the executable:
./csghub-portal start server
Once both services are running, open your web browser and visit:
This will allow you to view and interact with the application.