mark as done, CORS to be implemented
This commit is contained in:
parent
c08cd0bf32
commit
8079adf8d4
@ -1,3 +1,4 @@
|
||||
|
||||
# backend/Dockerfile
|
||||
FROM node:18-alpine AS builder
|
||||
|
||||
@ -16,10 +17,10 @@ RUN npm install
|
||||
RUN npm install -g @nestjs/cli
|
||||
|
||||
# Copy prisma files
|
||||
# COPY prisma ./prisma/
|
||||
COPY prisma ./prisma/
|
||||
|
||||
# Generate Prisma client
|
||||
# RUN npx prisma generate
|
||||
RUN npx prisma generate
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
@ -48,18 +49,22 @@ RUN npx prisma generate
|
||||
# Copy built application from builder stage
|
||||
COPY --from=builder /app/dist ./dist
|
||||
|
||||
# Create wait-for-db script
|
||||
RUN echo '#!/bin/sh\n\
|
||||
until pg_isready -h postgres -p 5432 -U ${POSTGRES_USER}; do\n\
|
||||
echo "Waiting for postgres...";\n\
|
||||
sleep 2;\n\
|
||||
# Create the start script
|
||||
RUN printf '#!/bin/sh\n\
|
||||
until pg_isready -h postgres -p 5432 -U ${POSTGRES_USER} -d ${POSTGRES_DB}; do\n\
|
||||
echo "Waiting for postgres..."\n\
|
||||
sleep 2\n\
|
||||
done\n\
|
||||
\n\
|
||||
echo "PostgreSQL is ready!"\n\
|
||||
\n\
|
||||
npx prisma migrate deploy\n\
|
||||
node dist/main.js' > /app/start.sh && chmod +x /app/start.sh
|
||||
node dist/main.js\n' > /app/start.sh
|
||||
|
||||
# Make the script executable
|
||||
RUN chmod +x /app/start.sh
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["/app/start.sh"]
|
||||
# Use shell form to ensure environment variables are expanded
|
||||
CMD ["/bin/sh", "/app/start.sh"]
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
RUN echo '#!/bin/sh\n\
|
||||
until pg_isready -h postgres -p 5432 -U ${POSTGRES_USER} -d ${POSTGRES_DB}; do\n\
|
||||
echo "Waiting for postgres...";\n\
|
||||
sleep 2;\n\
|
||||
done\n\
|
||||
\n\
|
||||
echo "PostgreSQL is ready!"\n\
|
||||
\n\
|
||||
npx prisma migrate deploy\n\
|
||||
node dist/main.js' > /app/start.sh && chmod +x /app/start.sh
|
||||
@ -12,6 +12,17 @@ services:
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
- POSTGRES_DB=${POSTGRES_DB}
|
||||
- JWT_SECRET=${JWT_SECRET}
|
||||
- SMTP_HOST=${SMTP_HOST}
|
||||
- SMTP_PORT=${SMTP_PORT}
|
||||
- SMTP_USER=${SMTP_USER}
|
||||
- SMTP_PASS=${SMTP_PASS}
|
||||
- SMTP_FROM=${SMTP_FROM}
|
||||
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
|
||||
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
|
||||
- AWS_REGION=${AWS_REGION}
|
||||
- AWS_BUCKET_NAME=${AWS_BUCKET_NAME}
|
||||
- AWS_ENDPOINT_URL=${AWS_ENDPOINT_URL}
|
||||
ports:
|
||||
- "3000:3000"
|
||||
depends_on:
|
||||
@ -24,8 +35,8 @@ services:
|
||||
container_name: imk-postgres
|
||||
image: postgres:14-alpine
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?schema=public
|
||||
# - NODE_ENV=production
|
||||
# - DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?schema=public
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
- POSTGRES_DB=${POSTGRES_DB}
|
||||
@ -36,7 +47,7 @@ services:
|
||||
networks:
|
||||
- imk_network
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
@ -2,8 +2,7 @@ import axios from "axios";
|
||||
|
||||
const API_URL =
|
||||
// process.env.NODE_ENV === "production"
|
||||
"https://imkapi.oblak.solutions";
|
||||
// : "http://localhost:3000";
|
||||
"https://imkapi.oblak.solutions" || "http://localhost:3000";
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: API_URL,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user