Compare commits
6 Commits
main
...
ad28e5629e
Author | SHA1 | Date | |
---|---|---|---|
ad28e5629e | |||
1ab34f6764 | |||
8dc5447953 | |||
b2ac178e06 | |||
d116623c80 | |||
e68638ec9c |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,7 +1,7 @@
|
|||||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
# Hosting
|
# Hosting
|
||||||
/host/convex/docker/data
|
/docker/data
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
node_modules
|
node_modules
|
||||||
|
42
README.md
42
README.md
@@ -31,29 +31,27 @@ I would recommend using [bun](https://bun.sh/) to install dependencies.
|
|||||||
bun i
|
bun i
|
||||||
```
|
```
|
||||||
|
|
||||||
You will also need docker installed on whatever host you plan to run the Supabase instance from, whether locally, or on a home server or a VPS or whatever. Or you can just use the Supabase SaaS if you want to have a much easier time, probably. I wouldn't know!
|
You will also need docker installed on whatever host you plan to run the Convex instance from, whether locally, or on a home server or a VPS or whatever. Or you can just use the Convex SaaS if you want to have a much easier time, probably. I wouldn't know!
|
||||||
|
|
||||||
### Add your environment variables
|
### Add your environment variables
|
||||||
|
|
||||||
Copy the example environment variable files and paste them in the same directory named `.env`.
|
Copy the example environment variable files and paste them in the same directory named `.env`.
|
||||||
|
|
||||||
|
Environment variables for Next Application
|
||||||
```bash
|
```bash
|
||||||
cp ./app/next/env.example ./app/next/.env
|
cp ./apps/next/env.example ./apps/next/.env
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Environment variables for Self Hosting Convex & Website with Docker
|
||||||
```bash
|
```bash
|
||||||
cp ./host/convex/docker/env.example ./host/convex/docker/.env
|
cp ./docker/env.example ./docker/.env
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
### Start self hosted convex & Next Web Application
|
||||||
cp ./host/next/docker/env.example ./host/next/docker/.env
|
|
||||||
```
|
|
||||||
|
|
||||||
### Start self hosted convex
|
|
||||||
|
|
||||||
The basic gist is to run the commands below after you have filled out the environment variables you plan to use, but you should ultimately follow the [guide they provide](https://github.com/get-convex/convex-backend/tree/main/self-hosted)
|
The basic gist is to run the commands below after you have filled out the environment variables you plan to use, but you should ultimately follow the [guide they provide](https://github.com/get-convex/convex-backend/tree/main/self-hosted)
|
||||||
```bash
|
```bash
|
||||||
cd ./host/convex/docker
|
cd ./docker
|
||||||
sudo docker compose up -d
|
sudo docker compose up -d
|
||||||
sudo docker compose exec convex-backend ./generate_admin_key.sh
|
sudo docker compose exec convex-backend ./generate_admin_key.sh
|
||||||
```
|
```
|
||||||
@@ -66,32 +64,6 @@ Run
|
|||||||
bun dev
|
bun dev
|
||||||
```
|
```
|
||||||
|
|
||||||
to start your development environment with turbopack
|
|
||||||
|
|
||||||
You can also run
|
|
||||||
|
|
||||||
```bash
|
|
||||||
bun dev:slow
|
|
||||||
```
|
|
||||||
|
|
||||||
to start your development environment with webpack (This is for the next app.)
|
|
||||||
|
|
||||||
### Start your Production Environment.
|
|
||||||
|
|
||||||
There are Dockerfiles & docker compose files that can be found in the `./scripts/docker` folder for the Next.js website. There is also a script called `reload_container` located in the `./scripts/` folder which was created to quickly update the container, but this will give you a better idea of what you need to do. First, build the image with
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo docker compose -f ./host/next/docker/compose.yml build
|
|
||||||
```
|
|
||||||
|
|
||||||
then you can run the container with
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo docker compose -f ./host/next/docker/compose up -d
|
|
||||||
```
|
|
||||||
|
|
||||||
Now, you may end up with some build errors. The `reload_containers` script swaps out the next config before it runs the docker build to skip any build errors, so you may want to do this as well, though you are welcome to fix the build errors as well, of course!
|
|
||||||
|
|
||||||
### Fin
|
### Fin
|
||||||
|
|
||||||
I am sure I am missing a lot of stuff so feel free to open an issue if you have any questions or if you feel that I should add something here!
|
I am sure I am missing a lot of stuff so feel free to open an issue if you have any questions or if you feel that I should add something here!
|
||||||
|
@@ -40,11 +40,13 @@ ENV NEXT_TELEMETRY_DISABLED=1
|
|||||||
# non-root user
|
# non-root user
|
||||||
RUN addgroup -S nodejs -g 1001 && adduser -S nextjs -u 1001
|
RUN addgroup -S nodejs -g 1001 && adduser -S nextjs -u 1001
|
||||||
COPY --from=builder /app/apps/next/public ./public
|
COPY --from=builder /app/apps/next/public ./public
|
||||||
|
RUN mkdir .next && chown -R nextjs:nodejs .next
|
||||||
RUN mkdir -p .next/cache && chown -R nextjs:nodejs .next
|
RUN mkdir -p .next/cache && chown -R nextjs:nodejs .next
|
||||||
|
|
||||||
# Next standalone output
|
# Next standalone output
|
||||||
COPY --from=builder /app/apps/next/.next/standalone ./
|
COPY --from=builder /app/apps/next/.next/standalone ./
|
||||||
COPY --from=builder /app/apps/next/.next/static ./.next/static
|
COPY --from=builder /app/apps/next/.next/static ./.next/static
|
||||||
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
|
|
||||||
USER nextjs
|
USER nextjs
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
@@ -1,7 +1,24 @@
|
|||||||
networks:
|
networks:
|
||||||
nginx-bridge: # Change this one line to match your network name in env file.
|
nginx-bridge: # You need to change this line to your defined network is as well
|
||||||
external: true
|
external: true
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
techtracker-next:
|
||||||
|
build:
|
||||||
|
context: ../
|
||||||
|
dockerfile: ./docker/Dockerfile
|
||||||
|
image: ${NEXT_CONTAINER_NAME}:alpine
|
||||||
|
container_name: ${NEXT_CONTAINER_NAME}
|
||||||
|
env_file: [.env]
|
||||||
|
hostname: ${NEXT_CONTAINER_NAME}
|
||||||
|
domainname: ${NEXT_DOMAIN_NAME}
|
||||||
|
networks: ['${NETWORK:-nginx-bridge}']
|
||||||
|
#ports: ['${NEXT_PORT}:3000']
|
||||||
|
depends_on: ['convex-backend']
|
||||||
|
tty: true
|
||||||
|
stdin_open: true
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
convex-backend:
|
convex-backend:
|
||||||
image: ghcr.io/get-convex/convex-backend:${BACKEND_TAG:-00bd92723422f3bff968230c94ccdeb8c1719832}
|
image: ghcr.io/get-convex/convex-backend:${BACKEND_TAG:-00bd92723422f3bff968230c94ccdeb8c1719832}
|
||||||
container_name: ${BACKEND_CONTAINER_NAME:-convex-backend}
|
container_name: ${BACKEND_CONTAINER_NAME:-convex-backend}
|
||||||
@@ -31,7 +48,6 @@ services:
|
|||||||
start_period: 10s
|
start_period: 10s
|
||||||
stop_grace_period: 10s
|
stop_grace_period: 10s
|
||||||
stop_signal: SIGINT
|
stop_signal: SIGINT
|
||||||
|
|
||||||
convex-dashboard:
|
convex-dashboard:
|
||||||
image: ghcr.io/get-convex/convex-dashboard:${DASHBOARD_TAG:-33cef775a8a6228cbacee4a09ac2c4073d62ed13}
|
image: ghcr.io/get-convex/convex-dashboard:${DASHBOARD_TAG:-33cef775a8a6228cbacee4a09ac2c4073d62ed13}
|
||||||
container_name: ${DASHBOARD_CONTAINER_NAME:-convex-dashboard}
|
container_name: ${DASHBOARD_CONTAINER_NAME:-convex-dashboard}
|
||||||
@@ -52,4 +68,3 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
stop_grace_period: 10s
|
stop_grace_period: 10s
|
||||||
stop_signal: SIGINT
|
stop_signal: SIGINT
|
||||||
|
|
@@ -1,4 +1,14 @@
|
|||||||
|
# Next Envrionment Variables
|
||||||
NETWORK=nginx-bridge
|
NETWORK=nginx-bridge
|
||||||
|
NEXT_CONTAINER_NAME=techtracker-next
|
||||||
|
NEXT_DOMAIN_NAME=techtracker.gbrown.org
|
||||||
|
# Port is disabled by default as suggested
|
||||||
|
# config is to have reverse proxy on the same
|
||||||
|
# network so you can just forward to the
|
||||||
|
# port on the internal network.
|
||||||
|
NEXT_PORT=3000
|
||||||
|
|
||||||
|
# Convex Environment Variables
|
||||||
BACKEND_TAG=00bd92723422f3bff968230c94ccdeb8c1719832
|
BACKEND_TAG=00bd92723422f3bff968230c94ccdeb8c1719832
|
||||||
BACKEND_CONTAINER_NAME=tt-convex-backend
|
BACKEND_CONTAINER_NAME=tt-convex-backend
|
||||||
BACKEND_DOMAIN_NAME=convex.gbrown.org
|
BACKEND_DOMAIN_NAME=convex.gbrown.org
|
@@ -2,7 +2,7 @@
|
|||||||
set -e # Exit immediately if a command exits with a non-zero status.
|
set -e # Exit immediately if a command exits with a non-zero status.
|
||||||
|
|
||||||
# --- Configuration ---
|
# --- Configuration ---
|
||||||
COMPOSE_FILE="./host/next/docker/compose.yml"
|
COMPOSE_FILE="./docker/compose.yml"
|
||||||
DEFAULT_PROJECT_NAME="techtracker"
|
DEFAULT_PROJECT_NAME="techtracker"
|
||||||
DEV_PROJECT_NAME="dev-techtracker" # The project name for dev mode
|
DEV_PROJECT_NAME="dev-techtracker" # The project name for dev mode
|
||||||
|
|
||||||
@@ -38,12 +38,12 @@ while [[ "$#" -gt 0 ]]; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# --- Main Script Logic ---
|
# --- Main Script Logic ---
|
||||||
echo "--- Pulling latest git changes ---"
|
echo "\n--- Pulling latest git changes ---\n"
|
||||||
git pull
|
git pull
|
||||||
echo "--- Building Docker Compose services ${COMPOSE_PROJECT_FLAG} ---"
|
echo "\n--- Building Docker Compose services ${COMPOSE_PROJECT_FLAG} ---\n"
|
||||||
sudo docker compose -p ${COMPOSE_PROJECT_FLAG} -f "${COMPOSE_FILE}" build
|
sudo docker compose -p ${COMPOSE_PROJECT_FLAG} -f "${COMPOSE_FILE}" build
|
||||||
echo "--- Bringing down Docker Compose services ${COMPOSE_PROJECT_FLAG} ---"
|
echo "\n--- Bringing down Docker Compose services ${COMPOSE_PROJECT_FLAG} ---\n"
|
||||||
sudo docker compose -p ${COMPOSE_PROJECT_FLAG} -f "${COMPOSE_FILE}" down
|
sudo docker compose -p ${COMPOSE_PROJECT_FLAG} -f "${COMPOSE_FILE}" down
|
||||||
echo "--- Bringing up Docker Compose services ${COMPOSE_PROJECT_FLAG} in detached mode ---"
|
echo "\n--- Bringing up Docker Compose services ${COMPOSE_PROJECT_FLAG} in detached mode ---\n"
|
||||||
sudo docker compose -p ${COMPOSE_PROJECT_FLAG} -f "${COMPOSE_FILE}" up -d
|
sudo docker compose -p ${COMPOSE_PROJECT_FLAG} -f "${COMPOSE_FILE}" up -d
|
||||||
echo "--- Script finished successfully ---"
|
echo "\n--- Script finished successfully ---\n"
|
@@ -1,49 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -e # Exit immediately if a command exits with a non-zero status.
|
|
||||||
|
|
||||||
# --- Configuration ---
|
|
||||||
COMPOSE_FILE="./host/convex/docker/compose.yml"
|
|
||||||
DEFAULT_PROJECT_NAME="techtracker"
|
|
||||||
DEV_PROJECT_NAME="dev-techtracker" # The project name for dev mode
|
|
||||||
|
|
||||||
COMPOSE_PROJECT_FLAG=${DEFAULT_PROJECT_NAME} # This will hold "-p dev-techtracker" if --dev is used
|
|
||||||
|
|
||||||
# --- Function to display usage ---
|
|
||||||
usage() {
|
|
||||||
echo "Usage: $0 [OPTIONS]"
|
|
||||||
echo "Or: ./update.sh [OPTIONS]" # Assuming the script is named update.sh
|
|
||||||
echo ""
|
|
||||||
echo "Options:"
|
|
||||||
echo " -d, --dev Run in development mode, using project name '${DEV_PROJECT_NAME}'."
|
|
||||||
echo " Adds '-p ${DEV_PROJECT_NAME}' to docker compose commands."
|
|
||||||
echo " -h, --help Display this help message."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# --- Parse arguments ---
|
|
||||||
while [[ "$#" -gt 0 ]]; do
|
|
||||||
case "$1" in
|
|
||||||
-d|--dev)
|
|
||||||
COMPOSE_PROJECT_FLAG=${DEV_PROJECT_NAME}
|
|
||||||
shift # Consume the argument
|
|
||||||
;;
|
|
||||||
-h|--help)
|
|
||||||
usage
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Error: Unknown argument '$1'" >&2
|
|
||||||
usage
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# --- Main Script Logic ---
|
|
||||||
echo "--- Pulling latest git changes ---"
|
|
||||||
git pull
|
|
||||||
echo "--- Building Docker Compose services ${COMPOSE_PROJECT_FLAG} ---"
|
|
||||||
sudo docker compose -p ${COMPOSE_PROJECT_FLAG} -f "${COMPOSE_FILE}" build
|
|
||||||
echo "--- Bringing down Docker Compose services ${COMPOSE_PROJECT_FLAG} ---"
|
|
||||||
sudo docker compose -p ${COMPOSE_PROJECT_FLAG} -f "${COMPOSE_FILE}" down
|
|
||||||
echo "--- Bringing up Docker Compose services ${COMPOSE_PROJECT_FLAG} in detached mode ---"
|
|
||||||
sudo docker compose -p ${COMPOSE_PROJECT_FLAG} -f "${COMPOSE_FILE}" up -d
|
|
||||||
echo "--- Script finished successfully ---"
|
|
@@ -1,18 +0,0 @@
|
|||||||
networks:
|
|
||||||
nginx-bridge: # You need to change this line to your defined network is as well
|
|
||||||
external: true
|
|
||||||
services:
|
|
||||||
techtracker-next:
|
|
||||||
build:
|
|
||||||
context: ../../../
|
|
||||||
dockerfile: ./host/next/docker/Dockerfile
|
|
||||||
image: ${CONTAINER_NAME}:alpine
|
|
||||||
container_name: ${CONTAINER_NAME}
|
|
||||||
env_file: [.env]
|
|
||||||
hostname: ${CONTAINER_NAME}
|
|
||||||
domainname: ${DOMAIN_NAME}
|
|
||||||
networks: ['${NETWORK:-nginx-bridge}']
|
|
||||||
#ports: ['${PORT}:3000']
|
|
||||||
tty: true
|
|
||||||
stdin_open: true
|
|
||||||
restart: unless-stopped
|
|
@@ -1,8 +0,0 @@
|
|||||||
NETWORK=nginx-bridge
|
|
||||||
CONTAINER_NAME=techtracker-next
|
|
||||||
DOMAIN_NAME=techtracker.gbrown.org
|
|
||||||
# Port is disabled by default as suggested
|
|
||||||
# config is to have reverse proxy on the same
|
|
||||||
# network so you can just forward to the
|
|
||||||
# port on the internal network.
|
|
||||||
PORT=3000
|
|
Reference in New Issue
Block a user