Skip to content

Commit

Permalink
feat: added Dockerfile to the frontend and backend and then configure…
Browse files Browse the repository at this point in the history
…d it
  • Loading branch information
stephane-segning committed Mar 2, 2024
1 parent c3f4636 commit 9a1269d
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 5 deletions.
10 changes: 6 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ services:
ports:
- "8080:8080"
depends_on:
- db
- postgres
environment:
- DATABASE_URL=postgres://postgres:password@db:5432/postgres
SPRING_DATASOURCE_URL: "jdbc:postgresql://postgres:5432/postgres"
SPRING_DATASOURCE_USERNAME: postgres
SPRING_DATASOURCE_PASSWORD: password

postgres:
image: postgres
Expand All @@ -30,14 +32,14 @@ services:
ports:
- "3000:80"
environment:
- REACT_APP_API_URL=http://localhost:3000
- REACT_APP_BACKEND_URL=http://api:8080

translator:
build:
context: ./power-pay-translator
dockerfile: Dockerfile
ports:
- "5000:5000"
- "5001:5000"
environment:
- BACKEND_API_URL=http://api:8080

Expand Down
Empty file added power-pay-backend/.dockerignore
Empty file.
6 changes: 6 additions & 0 deletions power-pay-backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
FROM eclipse-temurin:17

ENV APP_VERSION=0.0.1-SNAPSHOT

COPY target/power-pay-backend-$APP_VERSION.jar app.jar

ENTRYPOINT ["java", "-jar", "app.jar"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
spring:
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/postgres
username: postgres
password: password
3 changes: 3 additions & 0 deletions power-pay-frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
build
npm-debug.log
31 changes: 30 additions & 1 deletion power-pay-frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
FROM nginx
# Use the official Node.js runtime as the base image
FROM node:18 as build

# Set the working directory in the container
WORKDIR /app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy the entire application code to the container
COPY . .

# Build the React app for production
RUN npm run build

# Use Nginx as the production server
FROM nginx:stable-alpine

# Copy the built React app to Nginx's web server directory
COPY --from=build /app/dist /usr/share/nginx/html
COPY --from=build /app/nginx/nginx.conf /etc/nginx/conf.d/default.conf

# Expose port 80 for the Nginx server
EXPOSE 80

# Start Nginx when the container runs
CMD ["nginx", "-g", "daemon off;"]
8 changes: 8 additions & 0 deletions power-pay-frontend/nginx/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 9a1269d

Please sign in to comment.