Skip to content

Main #1

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build and Push Docker Images

on:
push:
branches:
- main

jobs:
build-and-push:
runs-on: ubuntu-latest


steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Login to GitHub Packages
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin

- name: Build and push backend image
working-directory: sample-fullstack-application\backend # Relative path to the backend directory
run: |
docker build -t docker.pkg.github.com/glitcher007/sample-fullstack-application/backend:latest .
docker push docker.pkg.github.com/glitcher007/sample-fullstack-application/backend:latest

- name: Build and push frontend image
working-directory: sample-fullstack-application\frontend # Relative path to the frontend directory
run: |
docker build -t docker.pkg.github.com/glitcher007/sample-fullstack-application/frontend:latest .
docker push docker.pkg.github.com/glitcher007/sample-fullstack-application/frontend:latest
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# Sample Fullstack Application

# Full Stack Application

## Running the Project with Docker

1. **Clone the Repository**:
```sh
git clone https://github.com/your-username/your-repo.git
cd your-repo
20 changes: 20 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dockerfile for React frontend
FROM node:14-alpine as build

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

RUN npm run build

FROM nginx:alpine

COPY --from=build /app/build /usr/share/nginx/html

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3'

services:
backend:
image: docker.pkg.github.com/glitcher007/sample-fullstack-application/backend:latest
ports:
- "3000:3000"

frontend:
image: docker.pkg.github.com/glitcher007/sample-fullstack-application/frontend:latest
ports:
- "80:80"
24 changes: 24 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Use an official Node.js image as the base image
FROM node:14-alpine

# Set the working directory inside the container
WORKDIR /app

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

# Install dependencies
RUN npm install

# Copy the rest of the application code to the working directory
COPY . .

# Build the application
RUN npm run build

# Expose port 3000 for the application
EXPOSE 3000

# Start the application
CMD ["npm", "start"]