Skip to content

Commit

Permalink
introduce docker compose and aws integration
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffbonson committed May 24, 2024
1 parent cca0cca commit ec70fb0
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 6 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/deploy-aws.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Deploy React-docker-aws-cicd app to AWS
on:
push:
branches:
- "main"

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2

- name: Generate deployment package
run: zip -r deploy.zip . -x '*.git*'

- name: Deploy to EB
uses: einaregilsson/beanstalk-deploy@v21
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: react-docker-aws-cicd
environment_name: React-aws-docker-cicd-env
version_label: ${{ github.sha }}
existing_bucket_name: elasticbeanstalk-us-east-1-976363746073
region: us-east-1
deployment_package: deploy.zip
17 changes: 12 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use a specific version of Node.js
FROM node:16.13.1-alpine
FROM node:16.13.1-alpine as builder

# Set the working directory in the container
WORKDIR /app
Expand All @@ -16,8 +16,15 @@ COPY . .
# Build the React app
RUN npm run build

# Expose port 3000 to the outside world
EXPOSE 3000
FROM nginx

# Define the command to run your app
CMD ["npm", "start"]
# Expose port 80 to the outside world
EXPOSE 80

# Copy the built React app to the Nginx html directory
COPY --from=builder /app/build /usr/share/nginx/html

# Start Nginx in the foreground
# CMD ["nginx", "start"] This command is typically used to start a development server using npm start. However, since you're using Nginx to serve the built React app, you don't need to run npm start

CMD ["nginx", "-g", "daemon off;"]
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '1'
services:
web:
build:
context: .
dockerfile: Dockerfile
ports:
- "80:80"
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function App() {
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Bookstore - React
Bookstore - React - 1.1
</p>

</header>
Expand Down

0 comments on commit ec70fb0

Please sign in to comment.