Skip to content

Commit

Permalink
Merge pull request #752 from twin-te/feature/staging
Browse files Browse the repository at this point in the history
ステージング環境用の設定を追加
  • Loading branch information
arata-nvm authored Mar 5, 2024
2 parents 80bbc76 + b22cc16 commit 9ea099f
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 9 deletions.
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# for localhost

NODE_ENV=development
VITE_APP_URL=https://app.twinte.net
VITE_API_URL=https://app.twinte.net/api/v3
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# for app.twinte.net

NODE_ENV=production
VITE_APP_URL=https://app.twinte.net
VITE_API_URL=https://app.twinte.net/api/v3
VITE_APP_SENTRY_URL=https://2fc5be4f95404937ada4d0127497fca4@o4504011477221376.ingest.sentry.io/4504226167324672
1 change: 1 addition & 0 deletions .env.staging
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# for app.dev.twinte.net

NODE_ENV=development
VITE_APP_URL=https://app.dev.twinte.net
VITE_API_URL=https://app.dev.twinte.net/api/v3
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: docker
name: docker (production)

on:
push:
Expand Down Expand Up @@ -42,6 +42,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: .
file: production.Dockerfile
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/docker-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: docker (staging)

on:
push:
branches:
- main

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: ghcr.io/twin-te/twinte-front
tag-custom: stg
tag-custom-only: true
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
-
name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: staging.Dockerfile
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
-
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
1 change: 1 addition & 0 deletions Dockerfile → production.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile

ENV VITE_APP_URL=https://app.twinte.net
ENV VITE_API_URL=https://app.twinte.net/api/v3

COPY . ./
Expand Down
3 changes: 2 additions & 1 deletion src/ui/templates/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useSwitch } from "~/ui/hooks/useSwitch";
import { getAuthState, setAuthState } from "~/ui/store/auth";
import { isVisibleSidebar, closeSidebar } from "~/ui/store/sidebar";
import { deleteToast, getToasts } from "~/ui/store/toast";
import { getAppUrl } from "~/ui/url";
import Sidebar from "./Sidebar.vue";
/** auth state */
Expand Down Expand Up @@ -77,7 +78,7 @@ const toasts = getToasts();
size="medium"
layout="fill"
color="primary"
@click="$router.push('/login?redirectUrl=https://app.twinte.net/')"
@click="$router.push(`/login?redirectUrl=${getAppUrl()}`)"
>
ログインする
</Button>
Expand Down
15 changes: 8 additions & 7 deletions src/ui/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ export const openUrl = (url: string) => {
}
};

export const getLoginUrl = (
provider: Provider,
redirectUrl = "https://app.twinte.net"
) => {
return `https://app.twinte.net/auth/v3/${provider}?redirect_url=${redirectUrl}`;
export const getAppUrl = () => {
return import.meta.env.VITE_APP_URL ?? "https://app.twinte.net";
};

export const getLogoutUrl = (redirectUrl = "https://app.twinte.net") => {
return `https://app.twinte.net/auth/v3/logout?redirect_url=${redirectUrl}`;
export const getLoginUrl = (provider: Provider, redirectUrl = getAppUrl()) => {
return `${getAppUrl()}/auth/v3/${provider}?redirect_url=${redirectUrl}`;
};

export const getLogoutUrl = (redirectUrl = getAppUrl()) => {
return `${getAppUrl()}/auth/v3/logout?redirect_url=${redirectUrl}`;
};

export const getSyllabusUrl = (year: number, code: string): string => {
Expand Down
15 changes: 15 additions & 0 deletions staging.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:16 AS builder
WORKDIR /app

COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile

ENV VITE_APP_URL=https://app.dev.twinte.net
ENV VITE_API_URL=https://app.dev.twinte.net/api/v3

COPY . ./
RUN yarn build:staging

FROM nginx
COPY production_nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/dist /usr/share/nginx/html

0 comments on commit 9ea099f

Please sign in to comment.