Hello all.
We’ve got a Docker Compose stack and we cannot for the life of us start this thing without getting the following error:
Our Dockerfile:
# Build stage
FROM node:16 as build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . ./
RUN npm run build
# Production stage
FROM nginx:alpine
COPY --from=build ./build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Install envsubst and ensure proper line endings
RUN apk add --no-cache gettext dos2unix
# Copy and prepare entrypoint script
COPY docker-entrypoint.sh ./docker-entrypoint.sh
RUN dos2unix ./docker-entrypoint.sh && chmod +x ./docker-entrypoint.sh
# Set default environment variable
ENV BACKEND_URL=http://backend.example.com:5001
EXPOSE 80
ENTRYPOINT ["./docker-entrypoint.sh"]
docker-compose.yml
version: '3'
services:
frontend:
build:
context: .
dockerfile: Dockerfile
ports:
- "8006:80"
environment:
- BACKEND_URL=http://backend.example.com:5001 # Replace with your actual backend URL
restart: unless-stopped
networks:
- frontend-network
networks:
frontend-network:
driver: bridge
docker-entrypoint.sh
#!/bin/sh
set -e
# Replace environment variables in nginx configuration
envsubst < /etc/nginx/conf.d/default.conf > /etc/nginx/conf.d/default.conf.tmp
mv /etc/nginx/conf.d/default.conf.tmp /etc/nginx/conf.d/default.conf
# Start nginx
exec nginx -g 'daemon off;'
We HAVE a docker-entrypoint.sh
file at the root of our Git repo, but try as we might, nothing we have done is working. I have no idea what to do here - none of our changes has resulted in any different error messages and I cannot for the life of me see why it cannot see a file that’s right there in the root.