Hello I'm trying to run a script to just start my yarn dev after my postgres is connected:
until psql -c '\l'; do
echo >&2 "$(date +%Y%m%dt%H%M%S) Postgres is unavailable - sleeping"
sleep 1
done
echo >&2 "$(date +%Y%m%dt%H%M%S) Postgres is up - executing command"
exec ${@}
docker file:
#building code
FROM node:lts-alpine
RUN mkdir -p /home/node/api && chown -R node:node /home/node/api
WORKDIR /home/node/api
COPY ormconfig.json .env package.json yarn.* ./
USER node
RUN yarn
COPY --chown=node:node . .
RUN apk add --no-cache openssl
COPY wait-pg.sh ./
RUN chmod +x /wait-pg.sh
ENTRYPOINT ["/wait-pg.sh"]
EXPOSE 4000
CMD ["yarn", "dev"]
docker compose:
version: '3.7'
services:
db-pg:
image: postgres:12
container_name: db-pg
ports:
- '${DB_PORT}:5432'
environment:
ALLOW_EMPTY_PASSWORD: 'no'
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASS}
POSTGRES_DB: ${DB_NAME}
volumes:
- ci-postgres-data:/data
ci-api:
build: .
container_name: ci-api
volumes:
- .:/home/node/api
- /home/node/api/node_modules
ports:
- '${SERVER_PORT}:${SERVER_PORT}'
depends_on:
- db-pg
command: ['./wait-pg.sh', 'yarn', 'dev']
logging:
driver: 'json-file'
options:
max-size: '10m'
max-file: '5'
volumes:
ci-postgres-data:
and get this error:
---> Running in c5add5098b70 ERROR: Unable to lock database: Permission denied ERROR: Failed to open apk database: Permission denied ERROR: Service 'ci-api' failed to build: The command '/bin/sh -c apk add --no-cache openssl' returned a non-zero code: 99