diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..25ae166 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +# Stage 1: Build the application +FROM node:20-alpine AS build + +# Set working directory +WORKDIR /app + +# Copy package.json and yarn.lock +COPY package.json yarn.lock ./ + +# Install dependencies +RUN yarn install --frozen-lockfile + +# Copy the rest of the application code +COPY . . + +# Build the application +RUN yarn build + +# Stage 2: Serve the application with Nginx +FROM nginx:alpine + +# Copy the built application from the build stage +COPY --from=build /app/dist /usr/share/nginx/html + +# Copy nginx configuration (optional, can be added later if needed) +# COPY nginx.conf /etc/nginx/conf.d/default.conf + +# Expose port 80 +EXPOSE 80 + +# Start Nginx server +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1922a85 --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +# Variables +IMAGE_NAME = white-nights-admin-panel +IMAGE_TAG = latest +FULL_IMAGE_NAME = $(IMAGE_NAME):$(IMAGE_TAG) +ARCHIVE_NAME = white-nights-admin-panel-image.zip + +# Default target +.PHONY: help +help: + @echo "Available commands:" + @echo " make build-image - Build Docker image" + @echo " make export-image - Build Docker image and export it to a zip archive" + @echo " make clean - Remove Docker image and zip archive" + @echo " make help - Show this help message" + +# Build Docker image +.PHONY: build-image +build-image: + @echo "Building Docker image: $(FULL_IMAGE_NAME)" + docker build -t $(FULL_IMAGE_NAME) . + +# Export Docker image to zip archive +.PHONY: export-image +export-image: build-image + @echo "Exporting Docker image to $(ARCHIVE_NAME)" + docker save $(FULL_IMAGE_NAME) | gzip > $(ARCHIVE_NAME) + @echo "Image exported successfully to $(ARCHIVE_NAME)" + +# Clean up +.PHONY: clean +clean: + @echo "Removing Docker image and zip archive" + -docker rmi $(FULL_IMAGE_NAME) 2>/dev/null || true + -rm -f $(ARCHIVE_NAME) 2>/dev/null || true + @echo "Clean up completed" + +# Default target when no arguments provided +.DEFAULT_GOAL := help \ No newline at end of file