Skip to content

Commit

Permalink
infra: add docker-compose and docker container for every project
Browse files Browse the repository at this point in the history
  • Loading branch information
no-treasure committed Oct 4, 2024
1 parent 7bc775b commit eb6ae87
Show file tree
Hide file tree
Showing 21 changed files with 233 additions and 57 deletions.
44 changes: 44 additions & 0 deletions apps/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Stage 1: Base image for building
FROM node:20-alpine AS base

# Install pnpm globally
RUN npm i -g pnpm

# Create working directory
WORKDIR /app

# Copy root package files and workspace config
COPY package.json pnpm-lock.yaml ./pnpm-workspace.yaml ./

# Copy source code for the backend
COPY ./apps/backend ./apps/backend
COPY ./prisma ./prisma
COPY ./tsconfig.json ./tsconfig.json
COPY ./libs ./libs
COPY ./.env ./.env

# # Install dependencies for all workspaces
RUN pnpm install --frozen-lockfile
RUN pnpm --filter @gym-mate/backend build:ts

# # Stage 2: Final image for production
# FROM node:20-alpine

# # Create working directory
# WORKDIR /app

# # Copy files from the build stage
# COPY --from=base /app/apps/backend /app
# COPY --from=base /app/node_modules /node_modules
# COPY --from=base /app/prisma /prisma
# COPY --from=base /app/tsconfig.json /tsconfig.json
# COPY --from=base /app/.env /.env
# COPY --from=base /app/package.json /package.json

# Expose port (if the backend uses port 3000)
EXPOSE 3000

# WORKDIR /app/backend
# Start the backend
# CMD ["pnpm", "start:backend"]
CMD ["sh", "-c", "pnpm prisma migrate deploy && pnpm start:backend"]
5 changes: 3 additions & 2 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"scripts": {
"test": "pnpm run build:ts && tsc -p test/tsconfig.json && tap --ts \"test/**/*.test.ts\"",
"start": "pnpm run build:ts && fastify start -l info dist/src/app.js",
"start": "node dist/src/index.js",
"build:ts": "tsc",
"watch:ts": "tsc -w",
"dev": "tsx watch src .env | pino-pretty --colorize",
Expand All @@ -34,7 +34,8 @@
"bcryptjs": "^2.4.3",
"dotenv": "^16.4.5",
"fastify": "^4.0.0",
"fastify-plugin": "^4.0.0"
"fastify-plugin": "^4.0.0",
"prisma": "^5.6.0"
},
"devDependencies": {
"@types/bcryptjs": "^2.4.6",
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ const fastify = Fastify({

app(fastify, {})

fastify.listen({ port: 3000 })
fastify.listen({ port: 3000, host: '0.0.0.0' })
34 changes: 12 additions & 22 deletions apps/frontend/.svelte-kit/ambient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ declare module '$env/static/private' {
export const NODE: string;
export const NVM_CD_FLAGS: string;
export const INIT_CWD: string;
export const WARP_HONOR_PS1: string;
export const TERM: string;
export const SHELL: string;
export const npm_package_devDependencies_vite: string;
Expand All @@ -45,9 +46,6 @@ declare module '$env/static/private' {
export const npm_package_scripts_dev: string;
export const npm_package_scripts_lint_ts: string;
export const npm_package_devDependencies_postcss_load_config: string;
export const ZDOTDIR: string;
export const ORIGINAL_XDG_CURRENT_DESKTOP: string;
export const MallocNanoZone: string;
export const npm_package_private: string;
export const npm_package_devDependencies__sveltejs_kit: string;
export const npm_config_registry: string;
Expand All @@ -64,56 +62,53 @@ declare module '$env/static/private' {
export const npm_package_devDependencies__sveltejs_adapter_static: string;
export const SSH_AUTH_SOCK: string;
export const __CF_USER_TEXT_ENCODING: string;
export const WARP_IS_LOCAL_SHELL_SESSION: string;
export const npm_package_devDependencies_postcss: string;
export const npm_execpath: string;
export const PAGER: string;
export const WARP_USE_SSH_WRAPPER: string;
export const npm_package_devDependencies_svelte: string;
export const LSCOLORS: string;
export const npm_config_frozen_lockfile: string;
export const PATH: string;
export const npm_package_dependencies_effector: string;
export const LaunchInstanceID: string;
export const USER_ZDOTDIR: string;
export const __CFBundleIdentifier: string;
export const PWD: string;
export const npm_command: string;
export const npm_package_scripts_preview: string;
export const npm_lifecycle_event: string;
export const LANG: string;
export const npm_package_name: string;
export const NODE_PATH: string;
export const npm_package_scripts_build: string;
export const VSCODE_GIT_ASKPASS_EXTRA_ARGS: string;
export const XPC_FLAGS: string;
export const npm_package_dependencies__farfetched_core: string;
export const npm_config_node_gyp: string;
export const XPC_SERVICE_NAME: string;
export const npm_package_version: string;
export const npm_package_devDependencies__sveltejs_adapter_auto: string;
export const VSCODE_INJECTION: string;
export const npm_package_dependencies__gym_mate_ui: string;
export const npm_package_devDependencies_autoprefixer: string;
export const npm_package_devDependencies_svelte_check: string;
export const SHLVL: string;
export const HOME: string;
export const npm_package_type: string;
export const VSCODE_GIT_ASKPASS_MAIN: string;
export const LESS: string;
export const LOGNAME: string;
export const npm_package_scripts_format: string;
export const npm_package_dependencies_effector_storage: string;
export const npm_lifecycle_script: string;
export const VSCODE_GIT_IPC_HANDLE: string;
export const LC_CTYPE: string;
export const SSH_SOCKET_DIR: string;
export const PKG_CONFIG_PATH: string;
export const NVM_BIN: string;
export const npm_config_user_agent: string;
export const VSCODE_GIT_ASKPASS_NODE: string;
export const GIT_ASKPASS: string;
export const npm_package_devDependencies__types_node: string;
export const npm_config__callcenter_registry: string;
export const DISPLAY: string;
export const npm_package_devDependencies__csstools_postcss_global_data: string;
export const npm_package_devDependencies_postcss_nested: string;
export const CONDA_CHANGEPS1: string;
export const SECURITYSESSIONID: string;
export const npm_package_scripts_check: string;
export const COLORTERM: string;
Expand Down Expand Up @@ -156,6 +151,7 @@ declare module '$env/dynamic/private' {
NODE: string;
NVM_CD_FLAGS: string;
INIT_CWD: string;
WARP_HONOR_PS1: string;
TERM: string;
SHELL: string;
npm_package_devDependencies_vite: string;
Expand All @@ -167,9 +163,6 @@ declare module '$env/dynamic/private' {
npm_package_scripts_dev: string;
npm_package_scripts_lint_ts: string;
npm_package_devDependencies_postcss_load_config: string;
ZDOTDIR: string;
ORIGINAL_XDG_CURRENT_DESKTOP: string;
MallocNanoZone: string;
npm_package_private: string;
npm_package_devDependencies__sveltejs_kit: string;
npm_config_registry: string;
Expand All @@ -186,56 +179,53 @@ declare module '$env/dynamic/private' {
npm_package_devDependencies__sveltejs_adapter_static: string;
SSH_AUTH_SOCK: string;
__CF_USER_TEXT_ENCODING: string;
WARP_IS_LOCAL_SHELL_SESSION: string;
npm_package_devDependencies_postcss: string;
npm_execpath: string;
PAGER: string;
WARP_USE_SSH_WRAPPER: string;
npm_package_devDependencies_svelte: string;
LSCOLORS: string;
npm_config_frozen_lockfile: string;
PATH: string;
npm_package_dependencies_effector: string;
LaunchInstanceID: string;
USER_ZDOTDIR: string;
__CFBundleIdentifier: string;
PWD: string;
npm_command: string;
npm_package_scripts_preview: string;
npm_lifecycle_event: string;
LANG: string;
npm_package_name: string;
NODE_PATH: string;
npm_package_scripts_build: string;
VSCODE_GIT_ASKPASS_EXTRA_ARGS: string;
XPC_FLAGS: string;
npm_package_dependencies__farfetched_core: string;
npm_config_node_gyp: string;
XPC_SERVICE_NAME: string;
npm_package_version: string;
npm_package_devDependencies__sveltejs_adapter_auto: string;
VSCODE_INJECTION: string;
npm_package_dependencies__gym_mate_ui: string;
npm_package_devDependencies_autoprefixer: string;
npm_package_devDependencies_svelte_check: string;
SHLVL: string;
HOME: string;
npm_package_type: string;
VSCODE_GIT_ASKPASS_MAIN: string;
LESS: string;
LOGNAME: string;
npm_package_scripts_format: string;
npm_package_dependencies_effector_storage: string;
npm_lifecycle_script: string;
VSCODE_GIT_IPC_HANDLE: string;
LC_CTYPE: string;
SSH_SOCKET_DIR: string;
PKG_CONFIG_PATH: string;
NVM_BIN: string;
npm_config_user_agent: string;
VSCODE_GIT_ASKPASS_NODE: string;
GIT_ASKPASS: string;
npm_package_devDependencies__types_node: string;
npm_config__callcenter_registry: string;
DISPLAY: string;
npm_package_devDependencies__csstools_postcss_global_data: string;
npm_package_devDependencies_postcss_nested: string;
CONDA_CHANGEPS1: string;
SECURITYSESSIONID: string;
npm_package_scripts_check: string;
COLORTERM: string;
Expand Down
12 changes: 7 additions & 5 deletions apps/frontend/.svelte-kit/generated/client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export const nodes = [
() => import('./nodes/8'),
() => import('./nodes/9'),
() => import('./nodes/10'),
() => import('./nodes/11')
() => import('./nodes/11'),
() => import('./nodes/12')
];

export const server_loads = [];
Expand All @@ -22,10 +23,11 @@ export const dictionary = {
"/app": [5,[2]],
"/app/profile": [6,[2]],
"/app/workout-programs": [7,[2]],
"/app/workout-programs/new": [8,[2]],
"/auth": [9,[3]],
"/auth/login": [10,[3]],
"/auth/signup": [11,[3]]
"/app/workout-programs/new": [9,[2]],
"/app/workout-programs/[id]": [8,[2]],
"/auth": [10,[3]],
"/auth/login": [11,[3]],
"/auth/signup": [12,[3]]
};

export const hooks = {
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/.svelte-kit/generated/client/nodes/10.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as component } from "../../../../src/routes/auth/login/+page.svelte";
export { default as component } from "../../../../src/routes/auth/+page.svelte";
2 changes: 1 addition & 1 deletion apps/frontend/.svelte-kit/generated/client/nodes/11.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as component } from "../../../../src/routes/auth/signup/+page.svelte";
export { default as component } from "../../../../src/routes/auth/login/+page.svelte";
2 changes: 1 addition & 1 deletion apps/frontend/.svelte-kit/generated/client/nodes/8.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as component } from "../../../../src/routes/app/workout-programs/new/+page.svelte";
export { default as component } from "../../../../src/routes/app/workout-programs/[id]/+page.svelte";
2 changes: 1 addition & 1 deletion apps/frontend/.svelte-kit/generated/client/nodes/9.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as component } from "../../../../src/routes/auth/+page.svelte";
export { default as component } from "../../../../src/routes/app/workout-programs/new/+page.svelte";
2 changes: 1 addition & 1 deletion apps/frontend/.svelte-kit/generated/server/internal.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions apps/frontend/.svelte-kit/types/route_meta_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"/app/workout-programs/new": [
"src/routes/+layout.ts"
],
"/app/workout-programs/[id]": [
"src/routes/+layout.ts"
],
"/auth": [
"src/routes/+layout.ts",
"src/routes/+layout.ts"
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/.svelte-kit/types/src/routes/$types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ type EnsureDefined<T> = T extends null | undefined ? {} : T;
type OptionalUnion<U extends Record<string, any>, A extends keyof U = U extends U ? keyof U : never> = U extends unknown ? { [P in Exclude<A, keyof U>]?: never } & U : never;
export type Snapshot<T = any> = Kit.Snapshot<T>;
type PageParentData = EnsureDefined<LayoutData>;
type LayoutRouteId = RouteId | "/" | "/app" | "/app/profile" | "/app/workout-programs" | "/app/workout-programs/new" | "/auth" | "/auth/login" | "/auth/signup" | null
type LayoutParams = RouteParams & { }
type LayoutRouteId = RouteId | "/" | "/app" | "/app/profile" | "/app/workout-programs" | "/app/workout-programs/[id]" | "/app/workout-programs/new" | "/auth" | "/auth/login" | "/auth/signup" | null
type LayoutParams = RouteParams & { id?: string }
type LayoutParentData = EnsureDefined<{}>;

export type PageServerData = null;
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/.svelte-kit/types/src/routes/app/$types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ type EnsureDefined<T> = T extends null | undefined ? {} : T;
type OptionalUnion<U extends Record<string, any>, A extends keyof U = U extends U ? keyof U : never> = U extends unknown ? { [P in Exclude<A, keyof U>]?: never } & U : never;
export type Snapshot<T = any> = Kit.Snapshot<T>;
type PageParentData = Omit<EnsureDefined<import('../$types.js').LayoutData>, keyof LayoutData> & EnsureDefined<LayoutData>;
type LayoutRouteId = RouteId | "/app" | "/app/profile" | "/app/workout-programs" | "/app/workout-programs/new"
type LayoutParams = RouteParams & { }
type LayoutRouteId = RouteId | "/app" | "/app/profile" | "/app/workout-programs" | "/app/workout-programs/[id]" | "/app/workout-programs/new"
type LayoutParams = RouteParams & { id?: string }
type LayoutParentData = EnsureDefined<import('../$types.js').LayoutData>;

export type PageServerData = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type * as Kit from '@sveltejs/kit';

type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
// @ts-ignore
type MatcherParam<M> = M extends (param : string) => param is infer U ? U extends string ? U : string : string;
type RouteParams = { id: string };
type RouteId = '/app/workout-programs/[id]';
type MaybeWithVoid<T> = {} extends T ? T | void : T;
export type RequiredKeys<T> = { [K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K; }[keyof T];
type OutputDataShape<T> = MaybeWithVoid<Omit<App.PageData, RequiredKeys<T>> & Partial<Pick<App.PageData, keyof T & keyof App.PageData>> & Record<string, any>>
type EnsureDefined<T> = T extends null | undefined ? {} : T;
type OptionalUnion<U extends Record<string, any>, A extends keyof U = U extends U ? keyof U : never> = U extends unknown ? { [P in Exclude<A, keyof U>]?: never } & U : never;
export type Snapshot<T = any> = Kit.Snapshot<T>;
type PageParentData = Omit<EnsureDefined<import('../../../$types.js').LayoutData>, keyof import('../../$types.js').LayoutData> & EnsureDefined<import('../../$types.js').LayoutData>;

export type EntryGenerator = () => Promise<Array<RouteParams>> | Array<RouteParams>;
export type PageServerData = null;
export type PageData = Expand<PageParentData>;
38 changes: 38 additions & 0 deletions apps/telegram-bot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Stage 1: Base image for building
FROM node:20-alpine AS base

# Install pnpm globally
RUN npm i -g pnpm

# Create working directory
WORKDIR /app

# Copy root package files and workspace config
COPY package.json pnpm-lock.yaml ./pnpm-workspace.yaml ./

# Copy source code for the bot
COPY ./apps/telegram-bot ./apps/telegram-bot
COPY ./prisma ./prisma
COPY ./tsconfig.json ./tsconfig.json
COPY ./libs ./libs
COPY ./.env ./.env

# Install dependencies for all workspaces
RUN pnpm install --frozen-lockfile
RUN pnpm --filter @gym-mate/telegram-bot build:ts

# Stage 2: Final image for production
FROM node:20-alpine

# Create working directory
WORKDIR /app

# Copy files from the build stage
COPY --from=base /app/apps/telegram-bot /app
COPY --from=base /app/node_modules /node_modules
COPY --from=base /app/prisma /prisma
COPY --from=base /app/tsconfig.json /tsconfig.json
COPY --from=base /app/.env /.env

# Start the bot
CMD ["npm", "start"]
2 changes: 2 additions & 0 deletions apps/telegram-bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"main": "index.js",
"scripts": {
"dev": "tsx watch ./src/main.ts",
"start": "node dist/main.js",
"build:ts": "tsc",
"test": "echo \"Error: no test specified\" && exit 1"
},
"license": "ISC",
Expand Down
Loading

0 comments on commit eb6ae87

Please sign in to comment.