Skip to content

Commit

Permalink
Merge branch 'main' into DEAR-98-happiness-data
Browse files Browse the repository at this point in the history
  • Loading branch information
smuefsmuef committed Jul 27, 2024
2 parents 8134af1 + 7818b97 commit a7a474b
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 22 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
!.next/static
!.next/standalone
.git
24 changes: 24 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Auth.js
AUTH_SECRET=
AUTH_TRUST_HOST=

# Github Provider
AUTH_GITHUB_ID=
AUTH_GITHUB_SECRET=

# Google Provider
AUTH_GOOGLE_ID=
AUTH_GOOGLE_SECRET=

# yappi DB
DATABASE_HOST=
DATABASE_PORT=
DATABASE_NAME=
DATABASE_USER=
DATABASE_PASSWORD=n

# JWT
JWT_SECRET=

# API
API_BASE_URL=
11 changes: 7 additions & 4 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ jobs:
run: |
REPO_NAME=ghcr.io/${{ github.repository_owner }}/dear-dev-frontend
LOWER_REPO_NAME=$(echo $REPO_NAME | tr '[A-Z]' '[a-z]')
docker build --build-arg SECRET_KEY_NEXT_AUTH=${{ secrets.SECRET_KEY_NEXT_AUTH }} -t $LOWER_REPO_NAME:latest .
docker build \
--build-arg SECRET_KEY_NEXT_AUTH=${{ secrets.SECRET_KEY_NEXT_AUTH }} \
--build-arg NEXT_PUBLIC_API_URL=http://yappi.ch \
-t $LOWER_REPO_NAME:latest .
docker push $LOWER_REPO_NAME:latest
deploy:
Expand Down Expand Up @@ -91,10 +94,10 @@ jobs:
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} <<'EOF'
echo '${{ secrets.SSH_ITALIAN_PASSWORD }}' | sudo -S su - ${{ secrets.SSH_ITALIAN_USER }} -c '
cd ~/yappi &&
docker-compose stop frontend nginx &&
docker-compose rm frontend nginx &&
docker-compose stop frontend &&
docker-compose rm frontend &&
docker pull ghcr.io/24fsiit16/dear-dev-frontend:latest
docker-compose up -d frontend nginx '
docker-compose up -d frontend'
EOF
- name: cleanup
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ yarn-error.log*

# local env files
.env*.local
.env*.production

# vercel
.vercel
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ WORKDIR /app
# Copy the package.json and package-lock.json file
COPY package*.json ./

# Accept build arguments
ARG NEXT_PUBLIC_API_URL

ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}

# Install the dependencies
Expand Down
9 changes: 0 additions & 9 deletions dear-dev-frontend.iml

This file was deleted.

18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3.8'

services:
yappi-app:
container_name: yappi_frontend
build:
context: .
dockerfile: Dockerfile
ports:
- '3000:3000'
env_file:
- .env.production
networks:
- yappi_network

networks:
yappi_network:
external: true
2 changes: 1 addition & 1 deletion lib/api/apiClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const API_BASE_URL = 'http://localhost:8080';
export const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL;

const setHeaders = (token: string) => ({
Authorization: `Bearer ${token}`,
Expand Down
9 changes: 8 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};
const nextConfig = {
images: {
domains: ['media.giphy.com'],
},
env: {
NEXT_PUBLIC_API_KEY: process.env.NEXT_PUBLIC_API_KEY,
},
};

export default nextConfig;
5 changes: 0 additions & 5 deletions next.config.ts

This file was deleted.

4 changes: 3 additions & 1 deletion providers/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ interface ExtendedSession extends Session {
error?: string | null;
}

const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL;

const AuthContext = React.createContext<ExtendedSession | null>(null);

interface AuthProviderProps {
Expand All @@ -31,7 +33,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
const sessionData = session as ExtendedSession;

const fetchUser = async (id: string, bearerToken: string) => {
const response = await fetch(`http://localhost:8080/v1/user/${id}`, {
const response = await fetch(`${API_BASE_URL}/v1/user/${id}`, {
headers: {
Authorization: `Bearer ${bearerToken}`,
},
Expand Down
Binary file removed public/assets/Smilies/angry.png
Binary file not shown.
Binary file removed public/assets/Smilies/cry.png
Binary file not shown.
Binary file removed public/assets/Smilies/sad.png
Binary file not shown.
Binary file removed public/assets/Smilies/shock.png
Binary file not shown.
Binary file removed public/assets/Smilies/sick.png
Binary file not shown.
Binary file removed public/assets/Smilies/smily.png
Binary file not shown.
Binary file removed public/assets/Smilies/very-happy.png
Binary file not shown.

0 comments on commit a7a474b

Please sign in to comment.