Skip to content
Merged

Dev #42

Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .github/workflows/deploy_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]
45 changes: 35 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 `<MONGODB_URI>` with a valid connection string:

```bash
docker run -d -p 3000:3000 \
-e MONGODB_URI="<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 `<USERNAME>` and `<PAT>` with your credentials:

```bash
echo <PAT> | docker login ghcr.io -u <USERNAME> --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)
4 changes: 2 additions & 2 deletions schema/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
type UpdateItemResponse,
type UpsertInventoryLotResponse,
type ApiErrorPayload,
} from "./types";
} from "./types.js";

import {
type AuthenticateUserPayload,
Expand All @@ -30,7 +30,7 @@ import {
type UpdateUserResponse,
type UserDraft,
type UserResource,
} from "./user";
} from "./user.js";

type FetchLike = typeof fetch;

Expand Down
8 changes: 4 additions & 4 deletions schema/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
4 changes: 2 additions & 2 deletions schema/src/user.ts
Original file line number Diff line number Diff line change
@@ -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];
Expand Down Expand Up @@ -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[] }>;
export type ListUsersResponse = ApiResponse<{ users: UserResource[] }>;
7 changes: 3 additions & 4 deletions schema/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}