Skip to content

Commit

Permalink
Ok maybe it works (unclear on Dockerfile)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed May 11, 2023
1 parent aa11d78 commit fea715e
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 282 deletions.
48 changes: 13 additions & 35 deletions Dockerfile
Expand Up @@ -5,21 +5,17 @@ ENV NODE_ENV production

RUN npm install -g pnpm

FROM base as deps
FROM base as build

WORKDIR /app

ADD package.json pnpm-lock.yaml pnpm-workspace.yaml .
ADD packages ./packages
ADD apps/web/package.json ./apps/web/package.json
ADD apps/api/package.json ./apps/api/package.json
ADD . .
# ADD package.json pnpm-lock.yaml pnpm-workspace.yaml .
# ADD packages ./packages
# ADD apps/web/package.json ./apps/web/package.json
# ADD apps/api/package.json ./apps/api/package.json
RUN pnpm install

# build web
FROM base as build-web

WORKDIR /app

ARG VERSION
ENV VERSION $VERSION

Expand All @@ -38,32 +34,14 @@ ENV API_SERVER $API_SERVER
ARG GOOGLE_CLIENT_ID
ENV GOOGLE_CLIENT_ID $GOOGLE_CLIENT_ID

COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/apps/web/node_modules ./node_modules
COPY --from=deps /app/packages/shared ./node_modules/@peated/shared
ADD apps/web/ .

RUN --mount=type=secret,id=SENTRY_AUTH_TOKEN \
SENTRY_AUTH_TOKEN="$(cat /run/secrets/SENTRY_AUTH_TOKEN)" \
npm run build

# build api
FROM base as build-api

WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/apps/api/node_modules ./node_modules
COPY --from=deps /app/packages/shared ./node_modules/@peated/shared

ADD apps/api/ .

RUN npm run build
pnpm build

# web service
FROM nginx:alpine as web

COPY --from=build-web /app/dist /usr/share/nginx/html
COPY --from=build /app/dist /usr/share/nginx/html

RUN rm /etc/nginx/conf.d/default.conf

Expand All @@ -74,13 +52,11 @@ EXPOSE 8043
CMD ["nginx", "-g", "daemon off;"]

# api service
FROM build-api as api
FROM build as api

WORKDIR /app

COPY --from=build-api /app/node_modules ./node_modules

ADD apps/api/ .
COPY --from=build /app/ ./

ARG VERSION
ENV VERSION $VERSION
Expand All @@ -92,4 +68,6 @@ ENV PORT 4000

EXPOSE 4000

CMD ["npm", "start"]
WORKDIR /app/apps/api

CMD ["pnpm", "start"]
3 changes: 2 additions & 1 deletion apps/web/package.json
Expand Up @@ -42,7 +42,8 @@
"workbox-range-requests": "^6.5.4",
"workbox-routing": "^6.5.4",
"workbox-strategies": "^6.5.4",
"workbox-streams": "^6.5.4"
"workbox-streams": "^6.5.4",
"workbox-window": "^6.5.4"
},
"proxy": "http://localhost:4000",
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/config.tsx
@@ -1,11 +1,11 @@
const config = {
ENV: import.meta.env.PROD ? "production" : "development",
DEBUG: import.meta.env.DEV,
GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID || "",
SENTRY_DSN: process.env.SENTRY_DSN || "",
API_SERVER: process.env.API_SERVER || "http://localhost:4000",
GOOGLE_CLIENT_ID: import.meta.env.GOOGLE_CLIENT_ID || "",
SENTRY_DSN: import.meta.env.SENTRY_DSN || "",
API_SERVER: import.meta.env.API_SERVER || "http://localhost:4000",

VERSION: process.env.VERSION || "",
VERSION: import.meta.env.VERSION || "",
GITHUB_REPO: "https://github.com/dcramer/peated",
};

Expand Down
6 changes: 0 additions & 6 deletions apps/web/src/main.tsx
Expand Up @@ -16,7 +16,6 @@ import createRoutes from "./routes";
import config from "./config";
import { AuthProvider } from "./hooks/useAuth";
import { OnlineStatusProvider } from "./hooks/useOnlineStatus";
import { register } from "./serviceWorkerRegistration";
import Spinner from "./components/spinner";

Sentry.init({
Expand Down Expand Up @@ -95,8 +94,3 @@ root.render(
</GoogleOAuthProvider>
</React.StrictMode>
);

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://cra.link/PWA
register();
80 changes: 0 additions & 80 deletions apps/web/src/service-worker.ts

This file was deleted.

150 changes: 0 additions & 150 deletions apps/web/src/serviceWorkerRegistration.ts

This file was deleted.

17 changes: 13 additions & 4 deletions apps/web/vite-env.d.ts
Expand Up @@ -6,12 +6,21 @@
/// <reference types="vite-plugin-pwa/info" />

interface ImportMetaEnv {
readonly VITE_GOOGLE_CLIENT_ID: string;
readonly VITE_SENTRY_DSN: string;
readonly VITE_API_SERVER: string;
readonly VITE_API_SERVER: string;
readonly GOOGLE_CLIENT_ID: string;
readonly SENTRY_DSN: string;
readonly API_SERVER: string;
readonly VERSION: string;
}

interface ImportMeta {
readonly env: ImportMetaEnv;
}

declare namespace NodeJS {
export interface ProcessEnv {
NODE_ENV: "development" | "production" | "test";
SENTRY_DSN?: string;
API_SERVER?: string;
VERSION?: string;
}
}

0 comments on commit fea715e

Please sign in to comment.