Skip to content

Commit

Permalink
Merge pull request #1 from davidhfrankelcodes/dockerized
Browse files Browse the repository at this point in the history
Dockerize
  • Loading branch information
aliciusschroeder authored Oct 23, 2024
2 parents 96d8aaf + 24493c1 commit fdcdc40
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Use an official Node.js runtime as a parent image
FROM node:20

# Set the working directory in the container
WORKDIR /app

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

# Install the app dependencies
RUN npm ci

# Copy the rest of the application code
COPY . .

# Build the application
RUN npm run build

# The build output is typically placed in the 'dist' directory
# Use a lightweight web server to serve the static files
# We’ll use NGINX for serving our static files
FROM nginx:alpine

# Copy the built files from the previous build stage to the NGINX directory
COPY --from=0 /app/dist /usr/share/nginx/html

# Expose port 80
EXPOSE 80

# Start NGINX server
CMD ["nginx", "-g", "daemon off;"]
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,39 @@ npm run build

After building, you'll find a single HTML file in the `dist` directory.

## 🐳 Using Docker

You can also run LocalGen-UI using Docker, which allows for easy deployment and eliminates the need for local installations. Follow these steps:

1. Ensure you have Docker and Docker Compose installed on your machine.

2. Clone the repository and navigate into the project directory:

```bash
git clone https://github.com/aliciusschroeder/localgen-ui.git
cd localgen-ui
```

3. Build and start the services using Docker Compose:

```bash
docker compose up --build
```

If you want to run it in detached mode (background), use:

```bash
docker compose up --build -d
```

4. Access LocalGen-UI in your browser at `http://localhost:8080`.

To stop the services, simply run:

```bash
docker compose down
```

## 🎮 Usage

1. Open LocalGen-UI in your browser.
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
localgen-ui:
build:
context: .
dockerfile: Dockerfile
container_name: localgen-ui
ports:
- "${HOST_PORT:-8080}:80" # Maps port 80 in the container to port 8080 on the host
# Optional: You can add environment variables or volume mappings if needed
environment:
NODE_ENV: ${NODE_ENV:-production} # Set the environment to production
restart: unless-stopped # Restart policy for the container

0 comments on commit fdcdc40

Please sign in to comment.