Building Applications

Learn how to build and deploy your Go applications with Gophel CLI.

Basic Build

Build and run a Go application:

Build and run an application named 'myapp' on port 8080

gophel build myapp --port 8080

This command will compile your Go application and start it on the specified port.

Environment Configuration

Build with specific environment settings:

Build and run with production environment settings

gophel build myapp --port 8080 --env production

Set custom environment variables:

Build using environment variables from a file

gophel build myapp --port 8080 --env-file .env.prod
Build Options

Build with specific Go build flags:

Build with optimized binary size

gophel build myapp --port 8080 --build-flags '-ldflags=-s -w'

Build for a specific platform:

Build for Linux AMD64 platform

gophel build myapp --port 8080 --os linux --arch amd64
Rebuilding Applications

Rebuild an existing application:

Rebuild and restart an existing application

gophel rebuild <ID> --port 8080

This will stop the current instance, rebuild the application, and start it again.

Best Practices
  • Use meaningful application names
  • Choose appropriate port numbers
  • Set up proper environment configurations
  • Use build flags for optimization
  • Keep track of application IDs