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

docker compose to run Web UI as container #931

Open
wants to merge 1 commit into
base: master
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
28 changes: 19 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
FROM node:alpine
# Use Node.js base image
FROM node:16

# Set the working directory
WORKDIR /app

# COPY the package.json file, update any deps and install them
COPY package.json .
RUN npm install
# Copy package.json and package-lock.json to cache dependencies
COPY package*.json ./

# Install dependencies
RUN npm install --legacy-peer-deps

# copy the whole source folder(the dir is relative to the Dockerfile
# Ensure Gatsby CLI is available in PATH
ENV PATH /app/node_modules/.bin:$PATH

# Copy the rest of the application files
COPY . .
CMD [ "npm", "run", "start" ]

FROM nginx
EXPOSE 80
COPY --from=builder /app/public /usr/share/nginx/html
# Expose Gatsby's default development port
EXPOSE 8000

# Default command to start Gatsby development server
# CMD ["gatsby", "develop", "-H", "0.0.0.0", "-p", "8000"]
CMD ["npm", "run", "start"]
48 changes: 30 additions & 18 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
services:
pola_web-init:
image: node:20.10.0-stretch
working_dir: /app
volumes:
- .:/app
command: npm install
pola_web:
image: node:20.10.0-stretch
working_dir: /app
volumes:
- .:/app
command: npm run develop -- -H=0.0.0.0
ports:
- 8000:8000
depends_on:
pola_web-init:
condition: service_completed_successfully
services:
# pola_web-init:
# image: node:16
# working_dir: /app
# volumes:
# - .:/app
# command: npm install
# pola_web:
# image: node:16
# working_dir: /app
# volumes:
# - .:/app
# command: npm run develop -- -H=0.0.0.0
# ports:
# - 8123:8000
# depends_on:
# pola_web-init:
# condition: service_completed_successfully
gatsby:
build:
context: .
dockerfile: Dockerfile
ports:
- '8000:8000' # Expose Gatsby development server
volumes:
- .:/app # Sync project files for hot-reloading
- /app/node_modules # Cache dependencies to avoid reinstallation
environment:
NODE_ENV: development
command: gatsby develop -H 0.0.0.0 -p 8000
4 changes: 4 additions & 0 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ const path = require('path');
// const { createFilePath } = require(`gatsby-source-filesystem`);
const FilterWarningsPlugin = require('webpack-filter-warnings-plugin');

require('dotenv').config({
path: `.env.${process.env.NODE_ENV}`,
});

exports.onCreateNode = ({ node, getNode, actions }) => {
const { createNodeField } = actions;
// if (node.internal.type === `MarkdownRemark`) {
Expand Down
Loading
Loading