Initial commit 4.

This commit is contained in:
fanmuchen 2025-05-07 14:17:54 +08:00
parent f1919ab7bd
commit 0381f6a0be
5 changed files with 26 additions and 92 deletions

View File

@ -6,32 +6,31 @@ This is to kick start a web project with nextjs as frontend and go server as bac
``` ```
starter/ starter/
├-- .env ├── .env
├-- sh/ ├── sh/ # Shell scripts for development and deployment automation
│ └── dev.sh │ ├── dev.sh
│ └── prod.sh
├── frontend/ ├── frontend/
│ ├── public/ │ ├── public/
│ ├── src/ │ ├── src/
│ │ ├── app/ │ │ └── app/
│ │ └── components/ │ │ ├── layout.tsx
│ │ ├── page.tsx
│ │ ├── favicon.ico
│ │ └── globals.css
│ ├── Dockerfile
│ ├── package.json │ ├── package.json
│ └── ... │ └── ...
└── backend/ └── backend/
├── internal/ ├── internal/
│ ├── handlers/ │ └── ...
│ ├── middleware/
│ ├── models/
│ └── routes/
├── go.mod
├── go.sum
├── main.go ├── main.go
└── Makefile └── ...
``` ```
## Configuration ## Configuration
All environmental variables should be managed in a centralized `.env` in the root dir of the repo, as we'll source them when running deploying scripts. All environmental variables should be managed in a centralized `.env` in the root dir of the repo, as we'll source them when running deploying scripts.
The only permitted way to test, build or run the project is through `sh/prod.sh`.
## Tooling Versions And Configurations ## Tooling Versions And Configurations

41
frontend/.gitignore vendored
View File

@ -1,41 +0,0 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
# env files (can opt-in for committing if needed)
.env*
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts

View File

@ -1,36 +0,0 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
## Getting Started
First, run the development server:
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
## Learn More
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

View File

@ -18,8 +18,18 @@ else
echo -e "${GREEN}Node.js version is correct: $NODE_VERSION${NC}" echo -e "${GREEN}Node.js version is correct: $NODE_VERSION${NC}"
fi fi
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$SCRIPT_DIR/.."
# Start the backend server
cd "$REPO_ROOT/backend" || exit 1
echo -e "${BLUE}Starting backend server...${NC}"
go run main.go &
BACKEND_PID=$!
echo -e "${GREEN}Backend server started with PID $BACKEND_PID.${NC}"
# Start the frontend dev server from anywhere in the repo # Start the frontend dev server from anywhere in the repo
cd "$(dirname "$0")/../frontend" || exit 1 cd "$REPO_ROOT/frontend" || exit 1
# Install dependencies # Install dependencies
if [ -f package.json ]; then if [ -f package.json ]; then

View File

@ -151,7 +151,9 @@ rm -rf "${TEMP_DIR}" || handle_error "Failed to clean up local temporary files"
echo -e "${GREEN}Deployment process completed!${NC}" echo -e "${GREEN}Deployment process completed!${NC}"
# Automatically tail logs after deployment # Automatically tail logs after deployment
echo -e "${GREEN}Tailing logs...${NC}" echo -e "${GREEN}Tailing logs...${NC}"
sh "$(dirname "$0")/log.sh" -f SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$SCRIPT_DIR/.."
sh "$SCRIPT_DIR/log.sh" -f
LOG_EXIT_CODE=$? LOG_EXIT_CODE=$?
if [ $LOG_EXIT_CODE -eq 130 ]; then if [ $LOG_EXIT_CODE -eq 130 ]; then
echo -e "${YELLOW}Log viewing interrupted by user.${NC}" echo -e "${YELLOW}Log viewing interrupted by user.${NC}"