Skip to content

Commit b7b5cf5

Browse files
gxjakkapRangsimanJerathrxptSupeemAFK
authored
feat: backup postgres to external s3 (#171)
* fix star nav layer in story (#159) * fix: update navbar styles (#162) * fix: update navbar styles * fix: team nav (#163) * fix: team nav * fix: typo p7 (#168) * feat: add backup solution for prod * feat: add backup solution for staging * fix: add r2 specific settings --------- Co-authored-by: Rangsiman Jerabunjerdchai <61783407+RangsimanJera@users.noreply.github.com> Co-authored-by: Theeraphat Jaingam <jain.theera@gmail.com> Co-authored-by: Peemmaphat Sripongsai <83326313+SupeemAFK@users.noreply.github.com>
1 parent f69ffe2 commit b7b5cf5

File tree

9 files changed

+113
-34
lines changed

9 files changed

+113
-34
lines changed

.env.example

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@ NEXT_PUBLIC_SERVER_URL=http://localhost:3001
1515

1616
NEXT_PUBLIC_WEB_URL=http://localhost:3000
1717

18+
NEXT_PUBLIC_STAFF_URL=https://localhost:3002
19+
1820
API_CORS_ORIGIN=http://localhost:3000
1921

2022
S3_ACCESS_KEY_ID=your-s3-access-key-id
2123
S3_SECRET_KEY=your-s3-secret-key
2224
S3_ENDPOINT=your-s3-endpoint
2325
S3_BUCKET_NAME=your-s3-bucket-name
2426

25-
NEXT_PUBLIC_STAFF_URL=https://localhost:3002
27+
S3_ACESS_KEY_ID_PGBACKREST=
28+
S3_SECRET_KEY_PGBACKREST=
29+
S3_BUCKET_NAME_PGBACKREST=
30+

apps/web/app/(protected)/_components/team-nav-menu-client.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function TeamNavMenuClient({ teamData }: { teamData: TeamData }) {
4444
</div>
4545
</button>
4646
</DropdownMenuTrigger>
47-
<DropdownMenuContent className="!border-1 w-[270px] rounded-[24px] !border-white/20 !bg-[#262626] p-2">
47+
<DropdownMenuContent className="!border-1 z-101 w-[270px] rounded-[24px] !border-white/20 !bg-[#262626] p-2">
4848
<Link href="/teams">
4949
<DropdownMenuItem className="flex w-full cursor-pointer items-center justify-between rounded-[24px] px-5 py-3 !text-white">
5050
<span className="text-nav-2">ทีมของฉัน</span>

apps/web/app/(protected)/register/(member)/_components/form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ function MemberRegisterForm(
528528
<FormControl>
529529
<div className="grid grid-cols-1 gap-4 lg:grid-cols-2 lg:gap-10">
530530
<FormDescription className="text-sm lg:text-base">
531-
3. สำเนา ปพ.7 (ระเบียนแสดงผลการเรียน) ฉบับจริง{" "}
531+
3. สำเนา ปพ.7 (ใบรับรองสถานภาพทางการเรียน) ฉบับจริง{" "}
532532
<span className="text-pink-300">*</span>
533533
</FormDescription>
534534
<div>

apps/web/app/_components/application/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const req: RequirementProps[] = [
5252
สำเนาบัตรประชาชน หรือบัตรประจำตัวสำหรับบุคคลที่ไม่ใช่สัญชาติไทย <br />
5353
(เฉพาะด้านหน้า)
5454
</span>,
55-
"สำเนา ปพ.7 (ระเบียนแสดงผลการเรียน) ฉบับจริงของผู้เข้าแข่งขัน",
55+
"สำเนา ปพ.7 (ใบรับรองสถานภาพทางการเรียน) ฉบับจริงของผู้เข้าแข่งขัน",
5656
"รูปถ่าย 1.5 นิ้ว ชุดนักเรียนของนักเรียนผู้เข้าแข่งขัน",
5757
],
5858
imgSrc: "/static/required-docs/1.webp",

apps/web/app/_components/navbar/cta.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const Landing = ({ isMobile }: { isMobile?: boolean }) => {
1414
}
1515
return (
1616
<Link href="/sign-in" className="2xl:h-full">
17-
<button className="hidden cursor-pointer items-center justify-center gap-4 rounded-full bg-gradient-to-r from-purple-400/50 to-pink-300/50 px-6 py-2 text-base shadow-xl shadow-black/25 lg:flex lg:gap-6 lg:px-8 lg:py-2.5 lg:text-lg 2xl:h-full 2xl:self-stretch 2xl:px-10 2xl:text-lg">
17+
<button className="text-button-2 hidden cursor-pointer items-center justify-center gap-4 whitespace-nowrap rounded-full bg-gradient-to-r from-purple-400/50 to-pink-300/50 shadow-xl shadow-black/25 lg:flex lg:h-full lg:px-8 lg:py-3 2xl:px-10 2xl:py-2.5">
1818
ลงทะเบียน
1919
</button>
2020
</Link>

apps/web/app/_components/navbar/index.tsx

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -79,33 +79,37 @@ export function Navbar({ links, CTAId, sections }: NavbarProps) {
7979
const isActive = (href: string) => active === href
8080
return (
8181
<div className="z-100 sticky top-0 w-full p-9 px-[24px] lg:px-[60px] 2xl:px-[160px]">
82-
<GlassCard className="flex items-center justify-between rounded-full pl-3 pr-5 backdrop-blur-md lg:pr-3">
83-
<div className="flex w-[142px] items-center justify-center pt-1 lg:w-[120px] 2xl:w-[180px]">
84-
<NavLink href={"/"}>
85-
<Image
86-
style={{ width: "100%", height: "auto", objectFit: "cover" }}
87-
width={500}
88-
height={242}
89-
src="/static/logo/Logo.webp"
90-
alt="Bangmod Hackathon"
91-
/>
92-
</NavLink>
82+
<GlassCard className="grid grid-cols-3 items-center rounded-full pl-3 pr-5 backdrop-blur-md lg:pr-3">
83+
<div className="flex items-center justify-start">
84+
<div className="flex w-[142px] items-center justify-center lg:w-[120px] 2xl:w-[180px]">
85+
<NavLink href={"/"}>
86+
<Image
87+
style={{ width: "100%", height: "auto", objectFit: "cover" }}
88+
width={500}
89+
height={242}
90+
src="/static/logo/Logo.webp"
91+
alt="Bangmod Hackathon"
92+
/>
93+
</NavLink>
94+
</div>
9395
</div>
94-
<div className="hidden items-center lg:flex lg:gap-2 2xl:justify-between 2xl:gap-2.5">
95-
{links.map((item, i) => {
96-
if (item.type === "normal" && !item.mobileOnly) {
97-
return (
98-
<NavLink
99-
key={item.label}
100-
className={`rounded-full px-3 py-3 text-white lg:px-3 2xl:px-6 ${isActive(item.href.replace("#", "")) ? "text-nav-1-selected liquid" : "text-nav-2"}`}
101-
href={item.href}>
102-
{item.label}
103-
</NavLink>
104-
)
105-
} else return <Fragment key={`${item.label}-${i}`}></Fragment>
106-
})}
96+
<div className="flex items-center justify-center">
97+
<div className="hidden items-center lg:flex lg:gap-2 2xl:gap-2.5">
98+
{links.map((item, i) => {
99+
if (item.type === "normal" && !item.mobileOnly) {
100+
return (
101+
<NavLink
102+
key={item.label}
103+
className={`z-10 whitespace-nowrap rounded-full px-4 py-3 text-white 2xl:px-6 2xl:py-4 ${isActive(item.href.replace("#", "")) ? "text-nav-1-selected liquid" : "text-nav-2"}`}
104+
href={item.href}>
105+
{item.label}
106+
</NavLink>
107+
)
108+
} else return <Fragment key={`${item.label}-${i}`}></Fragment>
109+
})}
110+
</div>
107111
</div>
108-
<div className="flex h-[70px] items-center">
112+
<div className="flex h-[70px] items-center justify-end">
109113
{CTA[CTAId]}
110114
<Drawer>
111115
<DrawerTrigger asChild>

docker-compose.prod.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,39 @@ services:
2525
reservations:
2626
memory: 512M
2727

28+
pgbackrest:
29+
image: ghcr.io/pgbackrest/pgbackrest:latest
30+
env_file: ".env"
31+
depends_on:
32+
postgres:
33+
condition: service_healthy
34+
volumes:
35+
- postgres_data:/var/lib/postgresql/data:ro
36+
- pgbackrest_repo:/var/lib/pgbackrest
37+
- ./pgbackrest:/etc/pgbackrest
38+
- ./pgbackrest-logs:/var/log/pgbackrest
39+
environment:
40+
PGBACKREST_STANZA: db
41+
networks:
42+
- app_network
43+
command: >
44+
sh -c "
45+
if [ ! -f /etc/pgbackrest/pgbackrest.conf ]; then
46+
echo '[global]' > /etc/pgbackrest/pgbackrest.conf &&
47+
echo 'repo1-type=s3' >> /etc/pgbackrest/pgbackrest.conf &&
48+
echo 'repo1-path=/var/lib/pgbackrest' >> /etc/pgbackrest/pgbackrest.conf &&
49+
echo 'repo1-s3-bucket=${S3_BUCKET_NAME_PGBACKREST}' >> /etc/pgbackrest/pgbackrest.conf &&
50+
echo 'repo1-s3-endpoint=${S3_ENDPOINT}' >> /etc/pgbackrest/pgbackrest.conf &&
51+
echo 'repo1-s3-region=auto' >> /etc/pgbackrest/pgbackrest.conf &&
52+
echo 'repo1-s3-uri-style=path' /etc/pgbackrest/pgbackrest.conf &&
53+
echo 'repo1-s3-key=${S3_ACCESS_KEY_ID_PGBACKREST}' >> /etc/pgbackrest/pgbackrest.conf &&
54+
echo 'repo1-s3-key-secret=${S3_SECRET_KEY_PGBACKREST}' >> /etc/pgbackrest/pgbackrest.conf &&
55+
echo '[db]' >> /etc/pgbackrest/pgbackrest.conf &&
56+
echo 'pg1-path=/var/lib/postgresql/data' >> /etc/pgbackrest/pgbackrest.conf ;
57+
fi &&
58+
tail -f /dev/null
59+
"
60+
2861
watchtower:
2962
image: containrrr/watchtower
3063
env_file: ".env"
@@ -102,6 +135,8 @@ services:
102135
volumes:
103136
postgres_data:
104137
driver: local
138+
pgbackrest_repo:
139+
driver: local
105140

106141
networks:
107142
app_network:

docker-compose.staging.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,39 @@ services:
2424
reservations:
2525
memory: 512M
2626

27+
pgbackrest:
28+
image: ghcr.io/pgbackrest/pgbackrest:latest
29+
env_file: ".env"
30+
depends_on:
31+
postgres:
32+
condition: service_healthy
33+
volumes:
34+
- postgres_data:/var/lib/postgresql/data:ro
35+
- pgbackrest_repo:/var/lib/pgbackrest
36+
- ./pgbackrest:/etc/pgbackrest
37+
- ./pgbackrest-logs:/var/log/pgbackrest
38+
environment:
39+
PGBACKREST_STANZA: db
40+
networks:
41+
- app_network
42+
command: >
43+
sh -c "
44+
if [ ! -f /etc/pgbackrest/pgbackrest.conf ]; then
45+
echo '[global]' > /etc/pgbackrest/pgbackrest.conf &&
46+
echo 'repo1-type=s3' >> /etc/pgbackrest/pgbackrest.conf &&
47+
echo 'repo1-path=/var/lib/pgbackrest' >> /etc/pgbackrest/pgbackrest.conf &&
48+
echo 'repo1-s3-bucket=${S3_BUCKET_NAME_PGBACKREST}' >> /etc/pgbackrest/pgbackrest.conf &&
49+
echo 'repo1-s3-endpoint=${S3_ENDPOINT}' >> /etc/pgbackrest/pgbackrest.conf &&
50+
echo 'repo1-s3-region=auto' >> /etc/pgbackrest/pgbackrest.conf &&
51+
echo 'repo1-s3-uri-style=path' /etc/pgbackrest/pgbackrest.conf &&
52+
echo 'repo1-s3-key=${S3_ACCESS_KEY_ID_PGBACKREST}' >> /etc/pgbackrest/pgbackrest.conf &&
53+
echo 'repo1-s3-key-secret=${S3_SECRET_KEY_PGBACKREST}' >> /etc/pgbackrest/pgbackrest.conf &&
54+
echo '[db]' >> /etc/pgbackrest/pgbackrest.conf &&
55+
echo 'pg1-path=/var/lib/postgresql/data' >> /etc/pgbackrest/pgbackrest.conf ;
56+
fi &&
57+
tail -f /dev/null
58+
"
59+
2760
watchtower:
2861
image: containrrr/watchtower
2962
env_file: ".env"

packages/ui/src/styles/globals.css

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,11 @@
238238
}
239239

240240
.group::before {
241-
background: radial-gradient(80% 80% at 50% 50%,
242-
var(--glow-color, rgba(159, 131, 220, 0.5)) 0%,
243-
transparent 70%);
241+
background: radial-gradient(
242+
80% 80% at 50% 50%,
243+
var(--glow-color, rgba(159, 131, 220, 0.5)) 0%,
244+
transparent 70%
245+
);
244246
}
245247

246248
.bg-home {
@@ -263,4 +265,4 @@
263265
background-image: url("/static/background-image/Home.webp");
264266
}
265267
}
266-
}
268+
}

0 commit comments

Comments
 (0)