-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from nekko-lab/add-cd
add cd
- Loading branch information
Showing
9 changed files
with
197 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}), | ||
], | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters