Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] Updated web and deploy backend configuration for reverse proxy & decoupled Plane Deploy URL generation for web #2135

Merged
merged 13 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ services:
dockerfile: ./web/Dockerfile.web
args:
DOCKER_BUILDKIT: 1
NEXT_PUBLIC_API_BASE_URL: "http://localhost:8000"
restart: always
command: /usr/local/bin/start.sh web/server.js web
depends_on:
Expand All @@ -22,7 +21,6 @@ services:
dockerfile: ./space/Dockerfile.space
args:
DOCKER_BUILDKIT: 1
NEXT_PUBLIC_API_BASE_URL: http://localhost:8000
restart: always
command: /usr/local/bin/start.sh space/server.js space
depends_on:
Expand Down Expand Up @@ -87,6 +85,9 @@ services:
env_file:
- .env
environment:
POSTGRES_USER: ${PGUSER}
POSTGRES_DB: ${PGDATABASE}
POSTGRES_PASSWORD: ${PGPASSWORD}
PGDATA: /var/lib/postgresql/data

plane-redis:
Expand Down
9 changes: 7 additions & 2 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ cp ./apiserver/.env.example ./apiserver/.env
# Generate the SECRET_KEY that will be used by django
echo -e "SECRET_KEY=\"$(tr -dc 'a-z0-9' < /dev/urandom | head -c50)\"" >> ./apiserver/.env

echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./web/.env
echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./space/.env
if [ -n "$1" ]
then
echo "hello"
Copy link
Contributor

@sriramveeraghanta sriramveeraghanta Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove hello

echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./web/.env
echo -e "\nNEXT_PUBLIC_API_BASE_URL=$1\nWEB_URL=$1" >> ./space/.env
fi


# Generate Prompt for taking tiptap auth key
echo -e "\n\e[1;38m Instructions for generating TipTap Pro Extensions Auth Token \e[0m \n"
Expand Down
4 changes: 2 additions & 2 deletions space/Dockerfile.space
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
USER root

ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000
ARG NEXT_PUBLIC_API_BASE_URL=""
ARG NEXT_PUBLIC_DEPLOY_WITH_NGINX=1

ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL
Expand All @@ -44,7 +44,7 @@ COPY --from=installer --chown=captain:plane /app/space/.next/standalone ./
COPY --from=installer --chown=captain:plane /app/space/.next ./space/.next
COPY --from=installer --chown=captain:plane /app/space/public ./space/public

ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000
ARG NEXT_PUBLIC_API_BASE_URL=""
ARG NEXT_PUBLIC_DEPLOY_WITH_NGINX=1

ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL
Expand Down
2 changes: 1 addition & 1 deletion space/services/authentication.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import APIService from "services/api.service";

class AuthService extends APIService {
constructor() {
super(process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async emailLogin(data: any) {
Expand Down
2 changes: 1 addition & 1 deletion space/services/file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface UnSplashImageUrls {

class FileServices extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async uploadFile(workspaceSlug: string, file: FormData): Promise<any> {
Expand Down
2 changes: 1 addition & 1 deletion space/services/issue.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import APIService from "services/api.service";

class IssueService extends APIService {
constructor() {
super(process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async getPublicIssues(workspace_slug: string, project_slug: string, params: any): Promise<any> {
Expand Down
2 changes: 1 addition & 1 deletion space/services/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import APIService from "services/api.service";

class ProjectService extends APIService {
constructor() {
super(process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async getProjectSettings(workspace_slug: string, project_slug: string): Promise<any> {
Expand Down
2 changes: 1 addition & 1 deletion space/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import APIService from "services/api.service";

class UserService extends APIService {
constructor() {
super(process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async currentUser(): Promise<any> {
Expand Down
2 changes: 1 addition & 1 deletion web/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ NEXT_PUBLIC_SLACK_CLIENT_ID=""
# For Telemetry, set it to "app.plane.so"
NEXT_PUBLIC_PLAUSIBLE_DOMAIN=""
# Public boards deploy URL
NEXT_PUBLIC_DEPLOY_URL=""
NEXT_PUBLIC_DEPLOY_URL="http://localhost:3000/spaces"
8 changes: 6 additions & 2 deletions web/Dockerfile.web
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ FROM node:18-alpine AS installer

RUN apk add --no-cache libc6-compat
WORKDIR /app
ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000
ARG NEXT_PUBLIC_API_BASE_URL=""
ARG NEXT_PUBLIC_DEPLOY_URL=""

# First install the dependencies (as they change less often)
COPY .gitignore .gitignore
Expand All @@ -26,6 +27,7 @@ COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
USER root
ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL
ENV NEXT_PUBLIC_DEPLOY_URL=$NEXT_PUBLIC_DEPLOY_URL

RUN yarn turbo run build --filter=web

Expand All @@ -45,8 +47,10 @@ COPY --from=installer /app/web/package.json .
COPY --from=installer --chown=captain:plane /app/web/.next/standalone ./
COPY --from=installer --chown=captain:plane /app/web/.next ./web/.next

ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000
ARG NEXT_PUBLIC_API_BASE_URL=""
ARG NEXT_PUBLIC_DEPLOY_URL=""
ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL
ENV NEXT_PUBLIC_DEPLOY_URL=$NEXT_PUBLIC_DEPLOY_URL

USER root
COPY start.sh /usr/local/bin/
Expand Down
6 changes: 5 additions & 1 deletion web/components/project/publish-project/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ export const PublishProjectModal: React.FC<Props> = observer(() => {
const [isUnpublishing, setIsUnpublishing] = useState(false);
const [isUpdateRequired, setIsUpdateRequired] = useState(false);

const plane_deploy_url = process.env.NEXT_PUBLIC_DEPLOY_URL ?? "http://localhost:4000";
let plane_deploy_url = process.env.NEXT_PUBLIC_DEPLOY_URL;

if (typeof window !== 'undefined' && !plane_deploy_url) {
plane_deploy_url= window.location.protocol + "//" + window.location.host + "/spaces";
}

const router = useRouter();
const { workspaceSlug } = router.query;
Expand Down
6 changes: 5 additions & 1 deletion web/layouts/app-layout/app-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ type Props = {
};

const { NEXT_PUBLIC_DEPLOY_URL } = process.env;
const plane_deploy_url = NEXT_PUBLIC_DEPLOY_URL ? NEXT_PUBLIC_DEPLOY_URL : "http://localhost:3001";
let plane_deploy_url = NEXT_PUBLIC_DEPLOY_URL

if (typeof window !== 'undefined' && !plane_deploy_url) {
plane_deploy_url= window.location.protocol + "//" + window.location.host + "/spaces";
}

const Header: React.FC<Props> = ({ breadcrumbs, left, right, setToggleSidebar, noHeader }) => {
const { projectDetails } = useProjectDetails();
Expand Down
8 changes: 4 additions & 4 deletions web/lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const requiredAuth = async (cookie?: string) => {

if (!token) return null;

const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.plane.so";
const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "https://api.plane.so";

let user: IUser | null = null;

Expand Down Expand Up @@ -41,7 +41,7 @@ export const requiredAdmin = async (workspaceSlug: string, projectId: string, co
const cookies = convertCookieStringToObject(cookie);
const token = cookies?.accessToken;

const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.plane.so";
const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "https://api.plane.so";

let memberDetail: IProjectMember | null = null;

Expand Down Expand Up @@ -75,7 +75,7 @@ export const requiredWorkspaceAdmin = async (workspaceSlug: string, cookie?: str
const cookies = convertCookieStringToObject(cookie);
const token = cookies?.accessToken;

const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.plane.so";
const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "https://api.plane.so";

let memberDetail: IWorkspaceMember | null = null;

Expand Down Expand Up @@ -119,7 +119,7 @@ export const homePageRedirect = async (cookie?: string) => {

let workspaces: IWorkspace[] = [];

const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.plane.so";
const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL !== undefined ? process.env.NEXT_PUBLIC_API_BASE_URL : "https://api.plane.so";

const cookies = convertCookieStringToObject(cookie);
const token = cookies?.accessToken;
Expand Down
2 changes: 1 addition & 1 deletion web/services/ai.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const trackEvent =

class AiServices extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async createGptTask(
Expand Down
2 changes: 1 addition & 1 deletion web/services/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { NEXT_PUBLIC_API_BASE_URL } = process.env;

class AnalyticsServices extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async getAnalytics(workspaceSlug: string, params: IAnalyticsParams): Promise<IAnalyticsResponse> {
Expand Down
2 changes: 1 addition & 1 deletion web/services/app-installations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { NEXT_PUBLIC_API_BASE_URL } = process.env;

class AppInstallationsService extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async addInstallationApp(workspaceSlug: string, provider: string, data: any): Promise<any> {
Expand Down
2 changes: 1 addition & 1 deletion web/services/authentication.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { NEXT_PUBLIC_API_BASE_URL } = process.env;

class AuthService extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async emailLogin(data: any) {
Expand Down
2 changes: 1 addition & 1 deletion web/services/cycles.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const trackEvent =

class ProjectCycleServices extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async createCycle(
Expand Down
2 changes: 1 addition & 1 deletion web/services/estimates.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const trackEvent =

class ProjectEstimateServices extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async createEstimate(
Expand Down
2 changes: 1 addition & 1 deletion web/services/file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface UnSplashImageUrls {

class FileServices extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async uploadFile(workspaceSlug: string, file: FormData): Promise<any> {
Expand Down
2 changes: 1 addition & 1 deletion web/services/inbox.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type {

class InboxServices extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async getInboxes(workspaceSlug: string, projectId: string): Promise<IInbox[]> {
Expand Down
2 changes: 1 addition & 1 deletion web/services/integration/csv.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const trackEvent =

class CSVIntegrationService extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async exportCSVService(
Expand Down
2 changes: 1 addition & 1 deletion web/services/integration/github.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const trackEvent =
const integrationServiceType: string = "github";
class GithubIntegrationService extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async listAllRepositories(workspaceSlug: string, integrationSlug: string): Promise<any> {
Expand Down
2 changes: 1 addition & 1 deletion web/services/integration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const trackEvent =

class IntegrationService extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async getAppIntegrationsList(): Promise<IAppIntegration[]> {
Expand Down
2 changes: 1 addition & 1 deletion web/services/integration/jira.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const trackEvent =

class JiraImportedService extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async getJiraProjectInfo(workspaceSlug: string, params: IJiraMetadata): Promise<IJiraResponse> {
Expand Down
2 changes: 1 addition & 1 deletion web/services/issues.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const trackEvent =

class ProjectIssuesServices extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async createIssues(
Expand Down
2 changes: 1 addition & 1 deletion web/services/modules.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const trackEvent =

class ProjectIssuesServices extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async getModules(workspaceSlug: string, projectId: string): Promise<IModule[]> {
Expand Down
2 changes: 1 addition & 1 deletion web/services/notifications.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {

class UserNotificationsServices extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async getUserNotifications(
Expand Down
2 changes: 1 addition & 1 deletion web/services/pages.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const trackEvent =

class PageServices extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async createPage(
Expand Down
2 changes: 1 addition & 1 deletion web/services/project-publish.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const trackEvent =

class ProjectServices extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async getProjectSettingsAsync(
Expand Down
2 changes: 1 addition & 1 deletion web/services/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const trackEvent =

export class ProjectServices extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async createProject(
Expand Down
2 changes: 1 addition & 1 deletion web/services/reaction.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const trackEvent =

class ReactionService extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async createIssueReaction(
Expand Down
2 changes: 1 addition & 1 deletion web/services/state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { ICurrentUserResponse, IState, IStateResponse } from "types";

class ProjectStateServices extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

async createState(
Expand Down
2 changes: 1 addition & 1 deletion web/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const trackEvent =

class UserService extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
super(NEXT_PUBLIC_API_BASE_URL !== undefined ? NEXT_PUBLIC_API_BASE_URL : "http://localhost:8000");
}

currentUserConfig() {
Expand Down
Loading
Loading