diff --git a/README.md b/README.md index bb5eb22..3546d31 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ npm install mvn install ``` 3. Create a Spotify Developer account and create a new application to get your client ID and client secret. -4. Rename `.env.example` file in the `client` directory to `.env` and fill-it with your client ID and client secret +4. Rename `.env.example` file in the `api` directory to `.env` and fill-it with your client ID and client secret 5. Add `http://localhost:4200/login` as a redirect URI in your Spotify application settings. ## Usage @@ -42,4 +42,4 @@ Then open your browser and visit `http://localhost:4200`. This project is licensed under the terms of the MIT license. ## Author -[@wissemgrari](https://www.github.com/wissemgrari) \ No newline at end of file +[@wissemgrari](https://www.github.com/wissemgrari) diff --git a/api/.dockerignore b/api/.dockerignore index 48aa3df..b1c13f4 100644 --- a/api/.dockerignore +++ b/api/.dockerignore @@ -1,2 +1,2 @@ target/ -*.log \ No newline at end of file +*.log diff --git a/api/.gitignore b/api/.gitignore index 8b3f220..afd694c 100644 --- a/api/.gitignore +++ b/api/.gitignore @@ -32,5 +32,4 @@ build/ ### VS Code ### .vscode/ -application-dev.yml -application-prod.yml +.env diff --git a/api/pom.xml b/api/pom.xml index 1deeac8..b16b6a5 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -26,6 +26,11 @@ lombok true + + me.paulschwarz + spring-dotenv + 4.0.0 + org.springframework.boot spring-boot-starter-test diff --git a/api/src/main/resources/.env.example b/api/src/main/resources/.env.example new file mode 100644 index 0000000..4ab854e --- /dev/null +++ b/api/src/main/resources/.env.example @@ -0,0 +1,2 @@ +SPOTIFY_CLIENT_ID= +SPOTIFY_CLIENT_SECRET= diff --git a/api/src/main/resources/application.yml b/api/src/main/resources/application.yml index eb4a1bd..bc0f0a7 100644 --- a/api/src/main/resources/application.yml +++ b/api/src/main/resources/application.yml @@ -1,6 +1,11 @@ server: port: 5000 -spring: - profiles: - active: dev \ No newline at end of file +cors: + allowed-origins: "http://localhost:4200" + +spotify: + redirect_uri: "http://localhost:4200/login" + code_verifier: 1WsKdLhdVqSxZy6U8pOWLEfedyLp9kG1SXGPR3dMBD0myA9C5kJiCXM9axaVPoZL + client_id: ${SPOTIFY_CLIENT_ID} + client_secret: ${SPOTIFY_CLIENT_SECRET} diff --git a/client/Dockerfile b/client/Dockerfile index 5c53e01..955ef56 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -1,3 +1,4 @@ +# Stage 1: Build the Angular application FROM node:20-alpine as build WORKDIR /client @@ -8,3 +9,17 @@ COPY yarn.lock ./ RUN yarn install +COPY . ./ + +RUN yarn run build + +# Stage 2: Serve the application with Nginx +FROM nginx:alpine3.19-slim + +WORKDIR /client + +COPY --from=build /client/dist/spotify-profile/ /usr/share/nginx/html + +COPY ./nginx.conf /etc/nginx/conf.d/default.conf + +CMD ["nginx", "-g", "daemon off;"] diff --git a/client/nginx.conf b/client/nginx.conf new file mode 100644 index 0000000..6939756 --- /dev/null +++ b/client/nginx.conf @@ -0,0 +1,8 @@ +server { + listen 80; + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html =404; + } +}