From 3ca1c285f080e493dbc3ee650eaabf8a10ce4595 Mon Sep 17 00:00:00 2001 From: Sin-Kang Date: Sat, 6 Jun 2026 23:06:28 +0900 Subject: [PATCH] feat: add dev container and publish image to GHCR Add .devcontainer (Node 24) for source-level development; generic, with no consumer-specific backend baked in. Make the vite proxy target configurable via VITE_PROXY_TARGET (defaults to http://localhost:8080) so the console can point at any backend. CI: build and push the nginx image to GHCR on main; PRs still build only (no push). --- .devcontainer/devcontainer.json | 18 ++++++++++++++++++ .github/workflows/ci.yml | 20 +++++++++++++++++--- vite.config.ts | 33 ++++++++++++++++++++------------- 3 files changed, 55 insertions(+), 16 deletions(-) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..c36a44a --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,18 @@ +{ + "name": "devslab-kit-admin-ui (Vue)", + "image": "mcr.microsoft.com/devcontainers/typescript-node:24", + "workspaceFolder": "/workspace", + "postCreateCommand": "npm install", + "forwardPorts": [5173], + "runArgs": ["--add-host=host.docker.internal:host-gateway"], + "customizations": { + "vscode": { + "extensions": [ + "Vue.volar", + "bradlc.vscode-tailwindcss", + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode" + ] + } + } +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e43a8be..27ef5b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,6 +70,9 @@ jobs: docker: runs-on: ubuntu-latest needs: build + permissions: + contents: read + packages: write steps: - uses: actions/checkout@v4 @@ -77,11 +80,22 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build image (no push) + # PR 에서는 로그인/푸시하지 않고 빌드만 검증한다. + - name: Log in to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push image uses: docker/build-push-action@v6 with: context: . - push: false - tags: devslab-kit-admin-ui:ci-${{ github.sha }} + push: ${{ github.event_name != 'pull_request' }} + tags: | + ghcr.io/devslab-kr/devslab-kit-admin-ui:latest + ghcr.io/devslab-kr/devslab-kit-admin-ui:${{ github.sha }} cache-from: type=gha cache-to: type=gha,mode=max diff --git a/vite.config.ts b/vite.config.ts index 09032e1..37537ae 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,22 +1,29 @@ -import { defineConfig } from 'vite' +import { defineConfig, loadEnv } from 'vite' import vue from '@vitejs/plugin-vue' import tailwindcss from '@tailwindcss/vite' import { fileURLToPath, URL } from 'node:url' // https://vite.dev/config/ -export default defineConfig({ - plugins: [vue(), tailwindcss()], - resolve: { - alias: { - '@': fileURLToPath(new URL('./src', import.meta.url)), +export default defineConfig(({ mode }) => { + const env = loadEnv(mode, process.cwd(), '') + + return { + plugins: [vue(), tailwindcss()], + resolve: { + alias: { + '@': fileURLToPath(new URL('./src', import.meta.url)), + }, }, - }, - server: { - proxy: { - '/admin/api': { - target: 'http://localhost:8080', - changeOrigin: true, + server: { + proxy: { + '/admin/api': { + // 기본값은 로컬 백엔드(중립). 이 repo 는 특정 백엔드(bookrecord 등)를 알지 않는다. + // 다른 백엔드를 가리키려면 .env.local 에 VITE_PROXY_TARGET 을 설정하라. + // 예) VITE_PROXY_TARGET=http://host.docker.internal:8080 + target: env.VITE_PROXY_TARGET || 'http://localhost:8080', + changeOrigin: true, + }, }, }, - }, + } })