commit 0c518d3c22fe89a9a1815c54a3ff510a595acb87 Author: mahmood Date: Tue Jul 22 23:04:56 2025 +0330 first commit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..5d814e54 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM node:20 + +WORKDIR /app +COPY . . + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +# Environment replacement process +ENTRYPOINT ["/entrypoint.sh"] + +ENV PORT=5200 +EXPOSE 5200 +CMD ["node", ".output/server/index.mjs"] \ No newline at end of file diff --git a/dokploy.yml b/dokploy.yml new file mode 100644 index 00000000..da3d0ed5 --- /dev/null +++ b/dokploy.yml @@ -0,0 +1,13 @@ +name: ssr-app +# dokploy.yml +build: + command: yarn install && yarn build + output_dir: .output + +run: + command: node .output/server/index.mjs + port: 5050 + +env: + NODE_ENV: production + MY_CUSTOM_VAR: "value" \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 00000000..684022cc --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +# Function to escape special characters for sed +escape_sed() { + printf '%s\n' "$1" | sed -e 's/[\/&]/\\&/g' -e 's/\./\\\./g' +} + +# Escape all URL variables +ESCAPED_SUPABASE_URL=$(escape_sed "$VITE_SUPABASE_URL") +ESCAPED_IMAGE_URL=$(escape_sed "$VITE_SUPABASE_BASE_IMAGE_URL") +ESCAPED_NODE_URL=$(escape_sed "$VITE_NODE_BASE_URL") + +# Replace placeholders with escaped values +find /usr/share/nginx/html -type f \( -name "*.js" -o -name "*.html" \) -exec sed -i \ + -e "s/__VITE_APP_TYPE__/${VITE_APP_TYPE}/g" \ + -e "s/__VITE_APP_NAME_FA__/${VITE_APP_NAME_FA}/g" \ + -e "s/__VITE_APP_NAME_EN__/${VITE_APP_NAME_EN}/g" \ + -e "s/__VITE_SUPABASE_URL__/${ESCAPED_SUPABASE_URL}/g" \ + -e "s/__VITE_SUPABASE_KEY__/${VITE_SUPABASE_KEY}/g" \ + -e "s/__VITE_SUPABASE_BASE_IMAGE_URL__/${ESCAPED_IMAGE_URL}/g" \ + -e "s/__VITE_NODE_BASE_URL__/${ESCAPED_NODE_URL}/g" \ + {} \; + +exec "$@" \ No newline at end of file