An optimized tech stack for efficiency, an all-in-one solution to quickly build modern web apps.
Development
-
Install docker and docker compose.
- Windows: Docker Desktop
- Linux: Guide from Digital Ocean
- Ubuntu >20.04: Guide from Thijmen Heuvelink
Ensure that you've cloned the repository and are on the correct path.
docker compose up
The stack is now accessible on your preferred browser at http://localhost:3000, the pocketbase interface can be found at http://localhost:3000/pb/_/
To stop the stack from running simply execute the CTRL + C
shortcut.
Production
-
Create a
.env
file:- Locate the
.env.sample
file in your project directory. - Duplicate or copy the contents of this file.
- Rename the duplicate or copied file to
.env
.
- Locate the
-
Configure the environment variable:
- Open the
.env
file in a text editor. - Locate the line that defines the
PRODUCTION
variable. - Set the value of
PRODUCTION
to"true"
(include the quotes).
- Open the
Unlike in the development steps we now add the
-d
flag which makes the service run in the background.
docker compose up -d
The stack is now accessible on your preferred browser at http://localhost:3000 or on a differently defined port as stated in the .env
file, the pocketbase interface can be found at http://localhost:3000/pb/_/
docker compose down
Install Node Packages
docker compose exec next npm i -D <package>
docker compose exec next npm r <package>
NPM
Modules
Next Navigation API
Instead of using next/navigation
you should opt for the helper at @helpers/navigation
, this is a replacement required by next-intl
it offers the same functionality.
Link
useRouter
Redirect
usePathname
Accessing Pocketbase
Pocketbase has a client executable, below is an example that outputs all available commands. You can learn more on how to use it here.
docker compose exec pocketbase pocketbase --help
CLI
Schema Snapshots
Executing the following will generate a schema snapshot in src/backend/migrations
, note that this process does not save any collection data.
docker compose exec pocketbase pocketbase migrate collections
Pocketbase
Migrations
Gravatar
This helper allows you to easily obtain an image URL from an email address using Gravatar API.
-
Import the helper into your route.
import gravatar from '@/helpers/gravatar'
-
Obtain the avatar from gravatar.
const avatar = gravatar('[email protected]')
This will return a URL from the Gravatar API which is an image. Here's an example result:
https://www.gravatar.com/avatar/372...ba9?s=200&r=g&d=identicon
-
(Optional) You can also choose the avatar style.
const avatar = gravatar('[email protected]', 'identicon')
You can choose between the following avatar types:
identicon
monsterid
wavatar
retro
robohash
The default icon style is
identicon
Here's an example of how you can use the Gravatar helper in your code. It is recommended to add a fallback image in case Gravatar doesn't return anything or to display while Gravatar is still loading.
import gravatar from '@/helpers/gravatar'
export default function Page() {
const [avatar, setAvatar] = useState<string>('<fallback_url>')
// This'll run once when the page loads.
useEffect(() => {
setAvatar(gravatar(user.email))
}, [])
return (
<>
<Image src={avatar} alt="" />
</>
)
}
Helpers
Avatars
Continuous Integration
The workflow has been set up to connect to any VPS via SSH as defined in the Repository Secrets.
-
Install docker and docker compose on your VPS.
- Windows: Docker Desktop
- Linux: Guide from Digital Ocean
- Ubuntu >20.04: Guide from Thijmen Heuvelink
-
Setup a Runner on GitHub
-
Create a new Runner
-
Navigate to
Settings > Actions > Runners
To set up a new self-hosted runner, follow the instructions provided by GitHub to configure the runner to listen for jobs. It is advisable to install it as a service.
-
-
Define environment variables
-
Navigate and create new secrets in
Settings > Secrets and variables > Actions
Name Expects Description SSH_KEY Private Key Generated private ssh-key which will beused to access the VPS. SSH_HOST IP Address The address of your VPS that runs theGitHub Actions Runner. SSH_USER Username System user which should be utilized for deployments. SSH_PORT Port Number The port that will be used to connectwith the VPS, default is 22. APP_ENV Environment Contents of the .env
file withadjusted values for deployment.
-
-
Define the branch in .github/deploy.yml
and modify it from being disabled
to an existing branch. Any modifications made to that particular branch will automatically trigger the Action, deploying your stack to your VPS.