Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/supabase #2

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
.git
.gitignore
*.md
dist
.next
out
46 changes: 46 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: eungeori

on:
push:
branches: ["main", "develop"]
pull_request:
branches: ["main", "develop"]

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
environment: development

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push the image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ecr-test
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG

- name: Deploy to Amazon ECS
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ecs-task-definition.json
service: your-ecs-service
cluster: your-cluster-name
wait-for-service-stability: true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

.env
.env.development
.env.production
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN npm install -g pnpm && pnpm --version

COPY . .

FROM base AS build
RUN pnpm install --frozen-lockfile

RUN pnpm run build

EXPOSE 3000
CMD [ "pnpm", "start" ]

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@supabase/supabase-js": "^2.45.4",
"@vanilla-extract/css": "^1.15.3",
"@vanilla-extract/sprinkles": "^1.6.3",
"classnames": "^2.5.1",
Expand Down
113 changes: 113 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import Image from "next/image";
import Logo from "@svgs/logo.svg";
import { useState } from "react";
import { supabase } from "./utils/supabase";

import {
loginTextBox,
Expand All @@ -28,6 +30,28 @@ type LoginBoxProps = {
};

const LoginBox = ({ image, text, bg, textColor, border, onClick }: LoginBoxProps) => {
const [title, setTitle] = useState<string>("");
const onSubmit = async () => {
console.log("ν•¨μˆ˜ 호좜");

if (!title) {
console.error("μ—…λ‹Ή");
return;
} else {
const { data, error, status } = await supabase
.from("todos")
.insert([{ title: title }])
.select();

if (error) {
console.log(error);
}
if (status === 201) {
console.log(data);
}
}
};

return (
<div
className={loginBox}
Expand All @@ -37,6 +61,8 @@ const LoginBox = ({ image, text, bg, textColor, border, onClick }: LoginBoxProps
border: border ? "1px solid #d2d5d6" : "none",
}}
>
<input onChange={(e) => setTitle(e.target.value)} />
<button onClick={onSubmit}>μ œμΆœν•˜κΈ°</button>
<div className={loginBoxContents} onClick={onClick}>
<Image src={image} alt={text} width={24} height={24} />
<p className={regular}>{text}</p>
Expand Down
6 changes: 6 additions & 0 deletions src/app/utils/supabase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { createClient } from "@supabase/supabase-js";

const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL as string;
const supabaseKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY as string;

export const supabase = createClient(supabaseUrl, supabaseKey);
Loading