Skip to content

Commit

Permalink
Dockerized the client
Browse files Browse the repository at this point in the history
  • Loading branch information
wissemgrari committed Apr 19, 2024
1 parent 1e01cda commit edb3923
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
[@wissemgrari](https://www.github.com/wissemgrari)
2 changes: 1 addition & 1 deletion api/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
target/
*.log
*.log
3 changes: 1 addition & 2 deletions api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ build/
### VS Code ###
.vscode/

application-dev.yml
application-prod.yml
.env
5 changes: 5 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>me.paulschwarz</groupId>
<artifactId>spring-dotenv</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/resources/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SPOTIFY_CLIENT_ID=
SPOTIFY_CLIENT_SECRET=
11 changes: 8 additions & 3 deletions api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
server:
port: 5000

spring:
profiles:
active: dev
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}
15 changes: 15 additions & 0 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Stage 1: Build the Angular application
FROM node:20-alpine as build

WORKDIR /client
Expand All @@ -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;"]
8 changes: 8 additions & 0 deletions client/nginx.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit edb3923

Please sign in to comment.