Skip to content

Commit

Permalink
Merge pull request #7 from nekko-lab/add-cd
Browse files Browse the repository at this point in the history
add cd
  • Loading branch information
pantyetta authored Nov 14, 2024
2 parents b2505b5 + 800f07b commit e39b279
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Node.js & TypeScript",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-22-bookworm"

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
46 changes: 46 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: ci

on:
push:
branches:
- "main"
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
# image registryの設定
env:
REGISTRY: ghcr.io
IMAGE: "ghcr.io/${{ github.repository }}:${{ github.sha }}"
# このリポジトリに対する書き込み権限を付与
permissions:
contents: write
packages: write
steps:
# チェックアウト
- name: Checkout
uses: actions/checkout@v4
# GitHub Container Registryへのログイン
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Container build and push
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./container/Dockerfile
push: true
tags: ${{ env.IMAGE }}
# Update k8s yaml
- name: chage docker image
uses: mikefarah/yq@master
with:
cmd: yq '.spec.template.spec.containers[0].image = env(IMAGE)' -i ${{ env.WORK_DIR }}container/manifest/sync/app.yaml
# Manifest commit
- name: commit
uses: stefanzweifel/git-auto-commit-action@v4
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ Cyber </> Music (サイバー ルート ミュージック) は、​音楽と

## Develop Stack
- Qwik
- Vite
- Vite

## Static Site Generator (Node.js)

```shell
npm run build.server
```
19 changes: 19 additions & 0 deletions adapters/static/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { staticAdapter } from "@builder.io/qwik-city/adapters/static/vite";
import { extendConfig } from "@builder.io/qwik-city/vite";
import baseConfig from "../../vite.config";

export default extendConfig(baseConfig, () => {
return {
build: {
ssr: true,
rollupOptions: {
input: ["@qwik-city-plan"],
},
},
plugins: [
staticAdapter({
origin: "https://numasai2024.nekko-lab.dev",
}),
],
};
});
59 changes: 59 additions & 0 deletions container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
ARG NODE_VERSION=22.11.0

################################################################################
# Use node image for base image for all stages.
FROM node:${NODE_VERSION}-alpine as base

# Set working directory for all build stages.
WORKDIR /usr/src/app

################################################################################
# Create a stage for installing production dependencies.
FROM base as deps

# Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /root/.yarn to speed up subsequent builds.
# Leverage bind mounts to package.json and yarn.lock to avoid having to copy them
# into this layer.
RUN --mount=type=bind,source=package.json,target=package.json \
# --mount=type=bind,source=yarn.lock,target=yarn.lock \
# --mount=type=cache,target=/root/.yarn \
npm install --frozen-lockfile

################################################################################
# Create a stage for building the application.
FROM deps as build

# Copy the rest of the source files into the image.
COPY . .

# Run the build script.
RUN npm run build

################################################################################
# Create a new stage to run the application with minimal runtime dependencies
# where the necessary files are copied from the build stage.
#FROM base as final
FROM nginx:1.26.2

# Use production node environment by default.
#ENV NODE_ENV production
#ENV ORIGIN https://numasai2024.nekko-lab.dev

# Run the application as a non-root user.
#USER node

# Copy package.json so that package manager commands can be used.
#COPY package.json .

# Copy the production dependencies from the deps stage and also
# the built application from the build stage into the image.
#COPY --from=deps /usr/src/app/node_modules ./node_modules
COPY --from=build /usr/src/app/dist /usr/share/nginx/html
#COPY --from=build /usr/src/app/server ./server

# Expose the port that the application listens on.
#EXPOSE 3000

# Run the application.
#CMD yarn serve
17 changes: 17 additions & 0 deletions container/manifest/sync/app-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app-ingress
spec:
ingressClassName: cloudflare-tunnel
rules:
- host: "numasai2024.nekko-lab.dev"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: app-svc
port:
number: 80
9 changes: 9 additions & 0 deletions container/manifest/sync/app-svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Service
metadata:
name: app-svc
spec:
ports:
- protocol: TCP
port: 80
targetPort: 80
17 changes: 17 additions & 0 deletions container/manifest/sync/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: app
spec:
replicas: 2
selector:
matchLabels:
app: app
template:
metadata:
labels:
app: app
spec:
containers:
- name: app
image: ""
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"build": "qwik build",
"build.client": "vite build",
"build.preview": "vite build --ssr src/entry.preview.tsx",
"build.server": "vite build -c adapters/static/vite.config.ts",
"build.types": "tsc --incremental --noEmit",
"deploy": "echo 'Run \"npm run qwik add\" to install a server adapter'",
"dev": "vite --mode ssr --host",
Expand Down

0 comments on commit e39b279

Please sign in to comment.