2
3

More than 1 year has passed since last update.

Astro Docker環境作成

Posted at

Astroとは

MPA(Multi Page Application)でSSG(Static Site Generator)でき、特定のフレームワークに依存しない独立したフレームワーク。
Astro | Build faster websites

簡易なDocker環境作成

※Dockerそのもののインストールは省略

以下のような状態でフォルダ・ファイルを作成。

astro-app
├─ app
├─ Dockerfile 
└─ docker-compose.yml

それぞれのファイル内容は以下

Dockerfile
FROM node:16.15.0-alpine
WORKDIR /usr/src/app
COPY ./app /app
EXPOSE 3000
docker-compose.yml
version: '3.9'
services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: astro-app
    volumes:
      - ./app:/usr/src/app
    ports:
      - "3000:3000"
    stdin_open: true
    tty: true

フォルダを作成したら以下の流れでコンテナを立ち上げ

cd astro-app
docker-compose build
docker-compose up -d
docker-compose ps

docker exec -it astro-app sh
→ /app に入る
npm create astro@latest

...プロジェクト作成時の設定を入力

npm run dev -- --host 0.0.0.0

localhost:3000 へアクセスすればAstroの初期表示
スクリーンショット 2023-02-15 15.04.03.png

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3