added docker
This commit is contained in:
17
.dockerignore
Normal file
17
.dockerignore
Normal file
@ -0,0 +1,17 @@
|
||||
node_modules
|
||||
npm-debug.log
|
||||
dist
|
||||
.git
|
||||
.gitignore
|
||||
Dockerfile
|
||||
Dockerfile*
|
||||
.dockerignore
|
||||
*.md
|
||||
*.tsbuildinfo
|
||||
.env
|
||||
.env.*
|
||||
.vscode
|
||||
.idea
|
||||
*.swp
|
||||
*.swo
|
||||
*.DS_Store
|
13
Dockerfile
13
Dockerfile
@ -1,11 +1,14 @@
|
||||
FROM node:22-alpine AS build
|
||||
# Use a Node image to build the Astro project
|
||||
FROM node:20-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
RUN npm install
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:alpine AS runtime
|
||||
# Use Nginx to serve the static site
|
||||
FROM nginx:alpine AS production
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
COPY ./nginx.conf /etc/nginx/nginx.conf
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
EXPOSE 8080
|
||||
EXPOSE 3000
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
@ -6,7 +6,7 @@ events {
|
||||
|
||||
http {
|
||||
server {
|
||||
listen 8080;
|
||||
listen 3000;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
|
30
src/Dockerfile
Normal file
30
src/Dockerfile
Normal file
@ -0,0 +1,30 @@
|
||||
# Use the official Astro image from Docker Hub
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install Astro CLI
|
||||
RUN npm create astro@latest -- --yes
|
||||
|
||||
# Copy your project files
|
||||
COPY . .
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install
|
||||
|
||||
# Build the Astro project
|
||||
RUN npm run build
|
||||
|
||||
# Production image
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/dist ./dist
|
||||
COPY --from=builder /app/package*.json ./
|
||||
|
||||
RUN npm install --production
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["npm", "start"]
|
Reference in New Issue
Block a user