Skip to content
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

feat: 73 Dockerize the monorepo #75

Closed
wants to merge 4 commits into from
Closed
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
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
.git
.DS_Store
npm-debug.log
33 changes: 33 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build and Push Docker Image

on:
push:
branches:
- main # Trigger on pushes to the main branch

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

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME_EGE }}
password: ${{ secrets.DOCKERHUB_PASSWORD_EGE }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: egenerse45/apollon2-webapp:latest, egenerse45/apollon2-webapp:v1.0

- name: Logout from Docker Hub
run: docker logout
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Stage 1: Builder
FROM node:20.18.0-slim AS builder

# Create and set working directory
WORKDIR /app

# Copy root-level package and lock files
COPY package*.json ./
# Copy workspace package files (if needed)
COPY library/package*.json ./library/
COPY standalone/webapp/package*.json ./standalone/webapp/
COPY standalone/server/package*.json ./standalone/server/

# Install all dependencies for the entire monorepo using npm ci
RUN npm install

# Copy all source code into the image
COPY . .

# Build the webapp - assuming there's a script at the root or
# you can directly run:
RUN npm run build

# Stage 2: Production image
FROM nginx:alpine
# Remove default nginx pages
RUN rm -rf /usr/share/nginx/html/*

# Copy the built webapp from the builder stage
COPY --from=builder /app/standalone/webapp/dist /usr/share/nginx/html

# Expose port 80
EXPOSE 80

# Default command to run nginx
CMD ["nginx", "-g", "daemon off;"]
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,20 @@ Here are the commonly used scripts defined in the monorepo:
npm run format:check
```

## Dockerized web app

Webapp can be build and run with docker. Be sure docker is installed in your device.

- **Build with docker :**
```bash
npm run docker:build
```
- **Run with docker :**
```bash
npm run docker:start
```
After running 'npm run docker:start' you can navigate to http://localhost:8080/ and start using the application

## Troubleshooting

- If you encounter issues with Node.js versions, ensure you have the correct version installed by running:
Expand Down
Loading
Loading