diff --git a/.github/workflows/deploy_image.yml b/.github/workflows/deploy_image.yml index dcb64b1..9296253 100644 --- a/.github/workflows/deploy_image.yml +++ b/.github/workflows/deploy_image.yml @@ -23,6 +23,8 @@ jobs: id-token: write # steps: + - name: Check out source + uses: actions/checkout@v4 # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. - name: Log in to the Container registry uses: docker/login-action@v3 diff --git a/Dockerfile b/Dockerfile index 5938427..200457b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,15 @@ FROM node:22-bookworm-slim AS build WORKDIR /app -ADD https://github.com/Accommodus/FoodStorageManager.git . -RUN rm -f package-lock.json && npm install +COPY package.json package-lock.json ./ +COPY server/package.json server/package.json +COPY client/package.json client/package.json +COPY schema/package.json schema/package.json +RUN npm ci + +# Copy the rest of the source and build the workspaces +COPY . . RUN npm run build FROM node:22-bookworm-slim AS runtime @@ -23,6 +29,7 @@ RUN npm ci --omit=dev COPY --from=build /app/server/dist ./server/dist COPY --from=build /app/client/dist ./client/dist +COPY --from=build /app/schema/dist ./schema/dist EXPOSE 3000 CMD ["npm", "--workspace=server", "run", "start"] diff --git a/README.md b/README.md index 5c0db81..94fc7eb 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,49 @@ -# Project Setup +# General Information -Initial setup adapted from [MERN + TypeScript Guide by Braily Guzman](https://brailyguzman.medium.com/mern-typescript-setup-guide-af1500100d4b). +This project is a MERN-based application configured with TypeScript and Docker support. The initial setup is adapted from the MERN + TypeScript guide by Braily Guzman: +[https://brailyguzman.medium.com/mern-typescript-setup-guide-af1500100d4b](https://brailyguzman.medium.com/mern-typescript-setup-guide-af1500100d4b) -## Local Development +A public Docker image is provided for general use, and a private development container image is available for contributors who need access to the development environment. -Start the development server and access the website at: -👉 [http://localhost:5173](http://localhost:5173) +# Installation Instructions -## Docker Registry Authentication +## User Guide (Public Application Image) -To push or pull Docker images from GitHub’s container registry (`ghcr.io`), follow these steps: +The public Docker image allows anyone to run the application without cloning the repository. To run the application, ensure Docker Desktop is running and confirm that no important process is using port 3000. If port 3000 is unavailable, the host port may be changed while keeping the container port at 3000, since the application is configured to listen on that internal port. For example, mapping port 8080 on the host would use `-p 8080:3000`. + +To start the container, run the command below and replace `` with a valid connection string: + +```bash +docker run -d -p 3000:3000 \ + -e MONGODB_URI="" \ + ghcr.io/accommodus/foodstoragemanager/app:latest +``` + +After the container starts, open a browser and navigate to `http://localhost:3000` or whichever host port you selected. You will be directed to the login page. Application credentials should be obtained from the project administrator. + +## Developer Guide (Local Development and Private Devcontainer Image) + +### Local Development + +Developers running the application locally can start the development server and access the site at: + +[http://localhost:5173](http://localhost:5173) + +### Accessing the Private Development Container Image + +Contributors who need to build or use the private devcontainer image must authenticate with GitHub’s container registry (`ghcr.io`). 1. **Generate a Personal Access Token (PAT)** - [Create a classic PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic) with the `read:packages` scopes. + Create a classic PAT with the `read:packages` scope: + [https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic) -2. **Authenticate with Docker** +2. **Authenticate Docker Using the PAT** Replace `` and `` with your credentials: ```bash echo | docker login ghcr.io -u --password-stdin ``` -For more details, see GitHub’s documentation on [authenticating to the container registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-to-the-container-registry). +After authentication, Docker will be able to pull the private devcontainer image used for development. Additional documentation on interacting with GitHub’s container registry is available here: + +[https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-to-the-container-registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-to-the-container-registry) diff --git a/schema/src/client.ts b/schema/src/client.ts index bd833f2..7fe1461 100644 --- a/schema/src/client.ts +++ b/schema/src/client.ts @@ -19,7 +19,7 @@ import { type UpdateItemResponse, type UpsertInventoryLotResponse, type ApiErrorPayload, -} from "./types"; +} from "./types.js"; import { type AuthenticateUserPayload, @@ -30,7 +30,7 @@ import { type UpdateUserResponse, type UserDraft, type UserResource, -} from "./user"; +} from "./user.js"; type FetchLike = typeof fetch; diff --git a/schema/src/index.ts b/schema/src/index.ts index 0dbed02..c63297b 100644 --- a/schema/src/index.ts +++ b/schema/src/index.ts @@ -3,8 +3,8 @@ export { type ClientInit, type RequestOptions, type SchemaClient, -} from "./client"; +} from "./client.js"; -export { toRole } from "./user"; -export type * from "./types"; -export type * from "./user"; +export { toRole } from "./user.js"; +export type * from "./types.js"; +export type * from "./user.js"; diff --git a/schema/src/user.ts b/schema/src/user.ts index d9cc33d..c6b8bc1 100644 --- a/schema/src/user.ts +++ b/schema/src/user.ts @@ -1,4 +1,4 @@ -import type { ApiResponse, ISODateString, ObjectIdString } from "./types"; +import type { ApiResponse, ISODateString, ObjectIdString } from "./types.js"; const allowedRoles = ["admin", "staff", "volunteer"] as const; export type Role = (typeof allowedRoles)[number]; @@ -34,4 +34,4 @@ export type AuthenticateUserResponse = ApiResponse<{ user: UserResource }>; export type CreateUserResponse = ApiResponse<{ user: UserResource }>; export type UpdateUserResponse = ApiResponse<{ user: UserResource }>; export type DeleteUserResponse = ApiResponse<{ deleted: boolean }>; -export type ListUsersResponse = ApiResponse<{ users: UserResource[] }>; \ No newline at end of file +export type ListUsersResponse = ApiResponse<{ users: UserResource[] }>; diff --git a/schema/tsconfig.json b/schema/tsconfig.json index f2739ea..4bd3e3a 100644 --- a/schema/tsconfig.json +++ b/schema/tsconfig.json @@ -1,15 +1,14 @@ { "compilerOptions": { "target": "ES2020", - "module": "ESNext", - "moduleResolution": "Bundler", + "module": "NodeNext", + "moduleResolution": "NodeNext", "outDir": "dist", "declaration": true, "declarationMap": false, "sourceMap": false, "strict": true, - "skipLibCheck": true, - "verbatimModuleSyntax": true + "skipLibCheck": true }, "include": ["src/index.ts", "src/client.ts", "src/types.ts"] }