-
Notifications
You must be signed in to change notification settings - Fork 8
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
Dockerize #26
Dockerize #26
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Use a Node.js base image for building | ||
FROM node:20.14 AS builder | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy package.json and package-lock.json | ||
COPY ./package.json ./package-lock.json ./ | ||
|
||
# Install dependencies | ||
RUN npm install | ||
|
||
# Copy source code | ||
COPY . . | ||
|
||
# Pass build-time environment variables (only available during build stage) | ||
ARG REACT_APP_API_URL | ||
ENV REACT_APP_API_URL=$REACT_APP_API_URL | ||
|
||
# Build the frontend app | ||
RUN npm run build | ||
|
||
# Use Nginx to serve the frontend build | ||
FROM nginx:1.23.2-alpine | ||
COPY --from=builder /app/build /usr/share/nginx/html | ||
|
||
# Expose necessary ports | ||
EXPOSE 80 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
version: "3.9" | ||
|
||
services: | ||
backend: | ||
build: | ||
context: ./server | ||
dockerfile: Dockerfile | ||
container_name: my-backend | ||
ports: | ||
- "5000:5000" | ||
env_file: | ||
- ./server/.env | ||
volumes: | ||
- ./server:/app | ||
- ./server/assets/public:/app/assets/public:ro | ||
networks: | ||
- mynetwork | ||
|
||
frontend: | ||
build: | ||
context: ./client | ||
dockerfile: Dockerfile | ||
args: | ||
REACT_APP_API_URL: "http://localhost:5000" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicated ENV/AGRS? |
||
container_name: my-frontend | ||
ports: | ||
- "3000:80" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to change to 80:80 ports |
||
environment: | ||
- REACT_APP_API_URL=http://localhost:5000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicated ENV/AGRS? |
||
- REACT_APP_NODE_ENV=development | ||
depends_on: | ||
- backend | ||
env_file: | ||
- ./client/.env | ||
networks: | ||
- mynetwork | ||
|
||
networks: | ||
mynetwork: | ||
driver: bridge |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Use a Node.js base image | ||
FROM node:20.14 | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy package.json and package-lock.json | ||
COPY ./package.json ./package-lock.json ./ | ||
|
||
# Install dependencies | ||
RUN npm install | ||
|
||
# Copy the rest of the backend code | ||
COPY . . | ||
|
||
# Expose the backend port | ||
EXPOSE 5000 | ||
|
||
# Run the backend | ||
CMD ["npm", "start"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ports on the back end need to be removed. Traffic should be go inside docker-compose network