diff --git a/app/.dockerignore b/.dockerignore similarity index 100% rename from app/.dockerignore rename to .dockerignore diff --git a/.gitignore b/.gitignore index 4c49bd7..ea8e13f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.env +**/.* +**/node_modules diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ec26278 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM postgrest/postgrest:v10.0.0 AS api +FROM amacneil/dbmate:1.15 AS dbmate +FROM node:18.7.0-alpine +RUN apk add --no-cache supervisor +COPY --from=api /bin/postgrest /usr/bin/ +COPY --from=dbmate /usr/local/bin/dbmate /usr/bin/ +COPY ./db ./db +COPY ./app ./app +RUN npm --prefix app ci --production +COPY ./docker-entrypoint.sh / +ENTRYPOINT ["/docker-entrypoint.sh"] +COPY ./supervisord.conf / +CMD ["supervisord", "-c", "/supervisord.conf"] diff --git a/app/.gitignore b/app/.gitignore deleted file mode 100644 index 3c3629e..0000000 --- a/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/app/Dockerfile b/app/Dockerfile deleted file mode 100644 index 8710b6e..0000000 --- a/app/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM node:18.7.0-alpine -WORKDIR /app -COPY . /app -RUN npm ci --production -CMD ["npm", "start"] diff --git a/compose.yml b/compose.yml index c8a5a74..760847e 100644 --- a/compose.yml +++ b/compose.yml @@ -1,29 +1,18 @@ services: - app: - image: kou029w/quot-app - build: app + quot: + image: kou029w/quot + build: "." restart: unless-stopped - init: true - user: ${UID:-1000}:${GID:-1000} ports: ["8080:8080"] - volumes: - - ./app:/app - environment: - QUOT_API_URL: http://api:3000/ - depends_on: [api] - api: - image: postgrest/postgrest:v10.0.0 - restart: unless-stopped environment: PGRST_DB_URI: postgresql://postgres:${POSTGRES_PASSWORD}@/postgres?host=/var/run/postgresql PGRST_DB_SCHEMA: public PGRST_DB_ANON_ROLE: postgres volumes: - postgres_socket:/var/run/postgresql - depends_on: - db: - condition: service_healthy + depends_on: [db] dbmate: + profiles: [dev] image: amacneil/dbmate:1.15 command: --wait up user: ${UID:-1000}:${GID:-1000} diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..97f26e2 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -e +dbmate --url "${PGRST_DB_URI}" --wait up +exec "$@" diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 0000000..bf9821a --- /dev/null +++ b/supervisord.conf @@ -0,0 +1,9 @@ +[supervisord] +nodaemon = true +user = root + +[program:app] +command = npm --prefix app start + +[program:api] +command = postgrest