Skip to content

Commit c8e4319

Browse files
committed
Init
Signed-off-by: Mihovil Ilakovac <[email protected]>
0 parents  commit c8e4319

22 files changed

+7676
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: "Deploy"
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
8+
# This will make sure that only one deployment is running at a time
9+
concurrency:
10+
group: deployment
11+
cancel-in-progress: true
12+
13+
env:
14+
WASP_VERSION: "0.15.1"
15+
# Put your server app name here
16+
SERVER_APP_NAME: "coolify-ghcr-server"
17+
# After you know the server URL, put the URL here
18+
SERVER_APP_URL: "https://api.miho.dev"
19+
# Put your client app name here
20+
CLIENT_APP_NAME: "coolify-ghcr-client"
21+
DOCKER_REGISTRY: "ghcr.io"
22+
DOCKER_REGISTRY_USERNAME: ${{ github.repository_owner }}
23+
# This secret is provided by GitHub by default and is used to authenticate with the Container registry
24+
DOCKER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
25+
WASP_TELEMETRY_DISABLED: 1
26+
27+
jobs:
28+
build-and-push-images:
29+
permissions:
30+
contents: read
31+
packages: write
32+
33+
runs-on: ubuntu-latest
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v4
38+
39+
- name: Log in to the Container registry
40+
uses: docker/login-action@v3
41+
with:
42+
registry: ghcr.io
43+
username: ${{ env.DOCKER_REGISTRY_USERNAME }}
44+
password: ${{ env.DOCKER_REGISTRY_PASSWORD }}
45+
46+
- name: (server) Extract metadata for Docker
47+
id: meta-server
48+
uses: docker/metadata-action@v5
49+
with:
50+
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REGISTRY_USERNAME }}/${{ env.SERVER_APP_NAME }}
51+
52+
- name: (client) Extract metadata for Docker
53+
id: meta-client
54+
uses: docker/metadata-action@v5
55+
with:
56+
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REGISTRY_USERNAME }}/${{ env.CLIENT_APP_NAME }}
57+
58+
- name: Install Wasp
59+
shell: bash
60+
run: curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s -- -v ${{ env.WASP_VERSION }}
61+
62+
- name: Build Wasp app
63+
shell: bash
64+
run: wasp build
65+
66+
- name: (client) Build
67+
shell: bash
68+
run: |
69+
cd ./.wasp/build/web-app
70+
REACT_APP_API_URL=${{ env.SERVER_APP_URL }} npm run build
71+
72+
- name: (client) Prepare the Dockerfile
73+
shell: bash
74+
run: |
75+
cd ./.wasp/build/web-app
76+
echo "FROM pierrezemb/gostatic" > Dockerfile
77+
echo "CMD [\"-fallback\", \"index.html\", \"-enable-logging\"]" >> Dockerfile
78+
echo "COPY ./build /srv/http" >> Dockerfile
79+
80+
- name: (server) Build and push Docker image
81+
uses: docker/build-push-action@v6
82+
with:
83+
context: ./.wasp/build
84+
file: ./.wasp/build/Dockerfile
85+
push: true
86+
tags: ${{ steps.meta-server.outputs.tags }}
87+
labels: ${{ steps.meta-server.outputs.labels }}
88+
89+
- name: (client) Build and push Docker image
90+
uses: docker/build-push-action@v6
91+
with:
92+
context: ./.wasp/build/web-app
93+
file: ./.wasp/build/web-app/Dockerfile
94+
push: true
95+
tags: ${{ steps.meta-client.outputs.tags }}
96+
labels: ${{ steps.meta-client.outputs.labels }}
97+
98+
# You can get the webhook URL from the Render dashboard
99+
# Put them in the repository secrets under RENDER_CLIENT_WEBHOOK_URL and RENDER_SERVER_WEBHOOK_URL
100+
- name: Trigger Deploy Webhooks
101+
env:
102+
CLIENT_COOLIFY_WEBHOOK: ${{ secrets.CLIENT_COOLIFY_WEBHOOK }}
103+
SERVER_COOLIFY_WEBHOOK: ${{ secrets.SERVER_COOLIFY_WEBHOOK }}
104+
COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }}
105+
run: |
106+
curl --request GET '${{ env.CLIENT_COOLIFY_WEBHOOK }}' --header 'Authorization: Bearer ${{ env.COOLIFY_TOKEN }}'
107+
curl --request GET '${{ env.SERVER_COOLIFY_WEBHOOK }}' --header 'Authorization: Bearer ${{ env.COOLIFY_TOKEN }}'

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.wasp/
2+
/.env.server
3+
/.env.client
4+
/node_modules

.waspignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore editor tmp files
2+
**/*~
3+
**/#*#

.wasproot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
File marking the root of Wasp project.

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# A Simple ToDo App w/ Typescript & Fullstack Type Saftey ⛑
2+
3+
## Running it locally
4+
5+
1. Make sure you have the latest version of [Wasp](https://wasp-lang.dev) installed by running `curl -sSL https://get.wasp-lang.dev/installer.sh | sh` in your terminal.
6+
2. Run `wasp new <project-name> -t todo-ts` to create a new app using this template.
7+
3. Run `wasp db migrate-dev`
8+
4. Run `wasp start`. This will install all dependencies and start the client and server for you :)
9+
5. Go to `localhost:3000` in your browser (your NodeJS server will be running on port `3001`)
10+
6. Install the Wasp extension for VSCode to get the best DX
11+
7. Check out the docs for more info on wasp's [features](https://wasp-lang.dev/docs/language/features) and step-by-step [guides](https://wasp-lang.dev/docs)
12+
13+
## Deploying with Coolify
14+
15+
[![Deploy](https://github.com/wasp-lang/coolify-ghcr/actions/workflows/deploy.yml/badge.svg)](https://github.com/wasp-lang/coolify-ghcr/actions/workflows/deploy.yml)
16+
17+
This app is deployed using Coolify and Github Container Repository.
18+
19+
It builds the app and Docker images for the server and the client in the Github action. The images are then pushed to the Github Container Registry.
20+
21+
Check the action source code here: https://github.com/wasp-lang/coolify-ghcr/blob/main/.github/workflows/deploy.yml
22+
23+
You'll need to create 2 resources that are deploy by using a Docker image (one for the server and one for the client) with Coolify and a PostgreSQL database.
24+
25+
You'll need to set the following environment variables for the server:
26+
27+
- `DATABASE_URL` - the connection string to your PostgreSQL database
28+
- `PORT` - the port on which the server will run (default is 3001)
29+
- `JWT_SECRET` - secret for JWT token
30+
- `WASP_SERVER_URL` - the URL of the server
31+
- `WASP_WEB_CLIENT_URL` - the URL of the client

main.wasp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
app coolifyGhcr {
2+
wasp: {
3+
version: "^0.15.0"
4+
},
5+
title: "Using Coolify is cool",
6+
7+
auth: {
8+
userEntity: User,
9+
methods: {
10+
usernameAndPassword: {}, // This is a very naive implementation, use 'email' in production instead
11+
//google: {}, // https://wasp-lang.dev/docs/integrations/google
12+
//gitHub: {}, // https://wasp-lang.dev/docs/integrations/github
13+
//email: {} // https://wasp-lang.dev/docs/guides/email-auth
14+
},
15+
onAuthFailedRedirectTo: "/login",
16+
}
17+
}
18+
19+
route RootRoute { path: "/", to: MainPage }
20+
page MainPage {
21+
authRequired: true,
22+
component: import { MainPage } from "@src/MainPage"
23+
}
24+
25+
route LoginRoute { path: "/login", to: LoginPage }
26+
page LoginPage {
27+
component: import { LoginPage } from "@src/auth/LoginPage"
28+
}
29+
30+
route SignupRoute { path: "/signup", to: SignupPage }
31+
page SignupPage {
32+
component: import { SignupPage } from "@src/auth/SignupPage"
33+
}
34+
35+
query getTasks {
36+
// We specify the JS implementation of our query (which is an async JS function)
37+
fn: import { getTasks } from "@src/tasks/queries",
38+
// We tell Wasp that this query is doing something with the `Task` entity. With that, Wasp will
39+
// automatically refresh the results of this query when tasks change.
40+
entities: [Task]
41+
}
42+
43+
action createTask {
44+
fn: import { createTask } from "@src/tasks/actions",
45+
entities: [Task]
46+
}
47+
48+
action updateTask {
49+
fn: import { updateTask } from "@src/tasks/actions",
50+
entities: [Task]
51+
}
52+
53+
action deleteTasks {
54+
fn: import { deleteTasks } from "@src/tasks/actions",
55+
entities: [Task],
56+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
-- CreateTable
2+
CREATE TABLE "User" (
3+
"id" SERIAL NOT NULL,
4+
5+
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
6+
);
7+
8+
-- CreateTable
9+
CREATE TABLE "Task" (
10+
"id" SERIAL NOT NULL,
11+
"description" TEXT NOT NULL,
12+
"isDone" BOOLEAN NOT NULL DEFAULT false,
13+
"userId" INTEGER NOT NULL,
14+
15+
CONSTRAINT "Task_pkey" PRIMARY KEY ("id")
16+
);
17+
18+
-- CreateTable
19+
CREATE TABLE "Auth" (
20+
"id" TEXT NOT NULL,
21+
"userId" INTEGER,
22+
23+
CONSTRAINT "Auth_pkey" PRIMARY KEY ("id")
24+
);
25+
26+
-- CreateTable
27+
CREATE TABLE "AuthIdentity" (
28+
"providerName" TEXT NOT NULL,
29+
"providerUserId" TEXT NOT NULL,
30+
"providerData" TEXT NOT NULL DEFAULT '{}',
31+
"authId" TEXT NOT NULL,
32+
33+
CONSTRAINT "AuthIdentity_pkey" PRIMARY KEY ("providerName","providerUserId")
34+
);
35+
36+
-- CreateTable
37+
CREATE TABLE "Session" (
38+
"id" TEXT NOT NULL,
39+
"expiresAt" TIMESTAMP(3) NOT NULL,
40+
"userId" TEXT NOT NULL,
41+
42+
CONSTRAINT "Session_pkey" PRIMARY KEY ("id")
43+
);
44+
45+
-- CreateIndex
46+
CREATE UNIQUE INDEX "Auth_userId_key" ON "Auth"("userId");
47+
48+
-- CreateIndex
49+
CREATE UNIQUE INDEX "Session_id_key" ON "Session"("id");
50+
51+
-- CreateIndex
52+
CREATE INDEX "Session_userId_idx" ON "Session"("userId");
53+
54+
-- AddForeignKey
55+
ALTER TABLE "Task" ADD CONSTRAINT "Task_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
56+
57+
-- AddForeignKey
58+
ALTER TABLE "Auth" ADD CONSTRAINT "Auth_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
59+
60+
-- AddForeignKey
61+
ALTER TABLE "AuthIdentity" ADD CONSTRAINT "AuthIdentity_authId_fkey" FOREIGN KEY ("authId") REFERENCES "Auth"("id") ON DELETE CASCADE ON UPDATE CASCADE;
62+
63+
-- AddForeignKey
64+
ALTER TABLE "Session" ADD CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "Auth"("id") ON DELETE CASCADE ON UPDATE CASCADE;

migrations/migration_lock.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Please do not edit this file manually
2+
# It should be added in your version-control system (i.e. Git)
3+
provider = "postgresql"

0 commit comments

Comments
 (0)