Skip to content

Commit

Permalink
Added Actions + New Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeyXs committed Apr 8, 2024
1 parent 74f68bd commit a36584b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 8 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/docker-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build and Push Docker Image

on:
push:
branches:
- master

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

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

- name: Login to GHCR.io
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.TOKEN }}

- name: Build Docker image
run: |
docker build -t home-zeyx-dev:latest .
docker tag home-zeyx-dev:latest ghcr.io/zeyxs/home-zeyx-dev:latest
- name: Push Docker image to GHCR.io
run: docker push ghcr.io/zeyxs/home-zeyx-dev:latest
24 changes: 17 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
FROM node:alpine AS builder
# Stage 1: Build the React app with Vite
FROM node:alpine AS build

WORKDIR /app

# Copy package.json and package-lock.json if applicable
COPY package*.json ./
RUN npm install

COPY . ./
# Install dependencies
RUN npm install

# Copy the rest of the application
COPY . .

# Build the React app
RUN npm run build

# Stage 2: Serve the built app using NGINX
FROM nginx:alpine

FROM nginx:alpine AS production
ENV NODE_ENV=production
# Copy the built app from the previous stage to NGINX directory
COPY --from=build /app/dist /usr/share/nginx/html

COPY --from=builder /app/dist /usr/share/nginx/html
# Copy custom nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Expose port 80
EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
# Start NGINX server
CMD ["nginx", "-g", "daemon off;"]
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ function App() {
);
};

export default App;
export default App;

0 comments on commit a36584b

Please sign in to comment.