Dockerization good to go
This commit is contained in:
1 parent
f319dcfc97
commit
9d793aa12c
3 files changed
+41
-5
No files matched your search
+1
-5
@@ -22,8 +22,4 @@ settings.json
|
|||||||
.env.production
|
.env.production
|
||||||
|
|
||||||
# macOS-specific files
|
# macOS-specific files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
#Docker Ignore
|
|
||||||
Dockerfile
|
|
||||||
docker-compose.yml
|
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
# Stage 1: Clone the repository and build the Astro project
|
||||||
|
FROM node:lts-alpine AS build
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install git and clone the repository
|
||||||
|
RUN apk add --no-cache git
|
||||||
|
ARG REPO_URL
|
||||||
|
RUN git clone $REPO_URL .
|
||||||
|
|
||||||
|
# Install dependencies and build the project
|
||||||
|
RUN npm install
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Stage 2: Serve the built application with a lightweight runtime image
|
||||||
|
FROM node:lts-alpine AS runtime
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy only the necessary files from the build stage
|
||||||
|
COPY --from=build /app/dist ./dist
|
||||||
|
COPY --from=build /app/node_modules ./node_modules
|
||||||
|
COPY --from=build /app/package.json .
|
||||||
|
|
||||||
|
# Set environment variables for the server
|
||||||
|
ENV HOST=0.0.0.0
|
||||||
|
ENV PORT=4321
|
||||||
|
|
||||||
|
# Expose the port the Astro app runs on
|
||||||
|
EXPOSE 4321
|
||||||
|
|
||||||
|
# Command to run the application
|
||||||
|
CMD ["node", "./dist/server/entry.mjs"]
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
services:
|
||||||
|
astro-app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
ports:
|
||||||
|
- "4321:4321"
|
||||||
|
volumes:
|
||||||
|
- .:/app
|
||||||
Reference in new issue
Block a user