feat(Docker): add docker integration

This commit is contained in:
Jewgeni Lewash 2024-02-17 09:39:19 +01:00
parent 2721e21e23
commit d8844bc907
4 changed files with 55 additions and 6 deletions

8
.dockerignore Normal file
View File

@ -0,0 +1,8 @@
.git
.github
.vscode
node_modules
.gitignore
CHANGELOG.md
README.md
dist

21
Dockerfile Normal file
View File

@ -0,0 +1,21 @@
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
WORKDIR /app
COPY package.json ./
COPY pnpm-lock.yaml ./
FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
FROM base AS build-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
FROM build-deps AS build
COPY . .
RUN pnpm run build
FROM nginx:alpine AS runtime
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80

View File

@ -3,14 +3,30 @@
## How to use this template ## How to use this template
```sh ```sh
npm i -g pnpm
git clone https://github.com/deployn/astro-deploy new-astro-project git clone https://github.com/deployn/astro-deploy new-astro-project
cd new-astro-project cd new-astro-project
pnpm install
pnpm build
pnpm preview
``` ```
Development Server:
```sh
npm i -g pnpm
pnpm install
pnpm dev
```
Production Build:
```sh
sudo docker build -t astro-deploy .
docker run -d -p 1234:80 astro-deploy
```
## Features
- 🚀 Astro.js 4
- 🐳 Docker integration
## 🧞 Commands ## 🧞 Commands
All commands are run from the root of the project, from a terminal: All commands are run from the root of the project, from a terminal:

View File

@ -3,7 +3,11 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title> <title>Astro Deploy</title>
</head> </head>
<body> </body> <body>
<main>
<div>Hello World</div>
</main>
</body>
</html> </html>