This guide provides a complete workflow for building the multi-store application, packaging it into a minimal container image with Podman, and distributing it via AWS S3 for local execution.
The goal is to create a self-contained, portable, and efficient artifact of the multi-store server. This allows any user (with credentials) to run the full application locally without needing to set up a full development environment.
The process is as follows:
Dockerfile builds the Next.js standalone server inside a container to ensure consistency.
graph TD
subgraph Dev[Developer Machine]
A[Repo Source Code] --> B[scripts build-image]
B --> C[Multi-store Dockerfile]
C --> D[Podman Image v1.0.7]
D --> E[scripts upload-image]
end
subgraph Cloud[AWS Cloud]
F[S3 Bucket]
end
subgraph User[User Machine]
G[Podman Installed] --> H[scripts run-container]
H --> F
H --> I[Running App Container]
end
E --> F
style B fill:#cde,stroke:#333,stroke-width:2px
style E fill:#cde,stroke:#333,stroke-width:2px
style H fill:#cde,stroke:#333,stroke-width:2px
Before you begin, ensure you have the following installed and configured on your system.
podman machine init).aws configure)..env file in the root of this repository.multi-store application to run.scripts/check-env.sh script is provided to help validate this file..env content:
# Payload
PAYLOAD_SECRET=YOUR_SUPER_SECRET_KEY
DATABASE_URI=mongodb://user:pass@host:port/db
# NextAuth
NEXTAUTH_SECRET=YOUR_NEXTAUTH_SECRET
# ... other variables
All scripts are located in the /scripts directory.
scripts/check-env.sh.env file exists and contains a minimal set of required keys.bash scripts/check-env.shscripts/build-image.shmulti-store container image using Podman.bash scripts/build-image.sh <version_tag>bash scripts/build-image.sh v1.0.7localhost/multi-store:v1.0.7.scripts/upload-image.shbash scripts/upload-image.sh <version_tag> <s3_bucket_name>bash scripts/upload-image.sh v1.0.7 my-app-imagesupload-image.ts TypeScript file.scripts/run-container.shbash scripts/run-container.sh <version_tag> [port]bash scripts/run-container.sh v1.0.7 8080localhost/multi-store:v1.0.7 image and map the container's port 3000 to your local port 8080. If no port is specified, it defaults to 3000..env file to the container.Here is how you would perform a full build and release:
Ensure .env is correct.
# Run the check manually if you want
bash scripts/check-env.sh
Build the image with a new version tag.
# Let's say the new version is 1.0.8
bash scripts/build-image.sh v1.0.8
Upload the new image to your S3 bucket.
bash scripts/upload-image.sh v1.0.8 my-flash-cms-images
(On another machine) Run the application.
.env file is also present on the user machine.# Run the container, exposing it on port 4000
bash scripts/run-container.sh v1.0.8 4000
You can now access the application at http://localhost:4000.