diff --git a/docker-compose.yml b/docker-compose.yml index 540a16b0..e511c545 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -53,6 +53,7 @@ services: - ./client/tsconfig.json:/opt/app/tsconfig.json depends_on: - strapi + - postgres networks: - strapi-network diff --git a/server/Dockerfile b/server/Dockerfile index 17585700..7978daa9 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -1,5 +1,8 @@ FROM node:22-alpine +# Install netcat for port checking +RUN apk add --no-cache netcat-openbsd + # Set working directory WORKDIR /opt/app @@ -15,8 +18,11 @@ COPY . . # Build the application RUN npm run build +# Make startup script executable +RUN chmod +x start.sh + # Expose port EXPOSE 1337 -# Start the application -CMD ["npm", "start"] \ No newline at end of file +# Start the application with the startup script +CMD ["./start.sh"] \ No newline at end of file diff --git a/server/start.sh b/server/start.sh new file mode 100644 index 00000000..448bbb7c --- /dev/null +++ b/server/start.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# Start Strapi in the background +npm start & +STRAPI_PID=$! + +# Wait for Strapi to be ready (check if port 1337 is listening) +echo "Waiting for Strapi to be ready..." +while ! nc -z localhost 1337; do + sleep 2 +done + +echo "Strapi is ready! Running config-sync import..." +npm run cs import + +# Wait for the Strapi process +wait $STRAPI_PID \ No newline at end of file