I have an e-commerce app and i deployed it in ec2 ubuntu instance with docker hub and github actions. I’m exposing my app in port 3000 and i created a 3000 port in the security group of my instance. So the url to access my app is http://ec2-3-29-107-165.me-central-1.compute.amazonaws.com:3000/.
I wanted to see if everything is ok and there are no issues but the profil page is not getting the addresses of the current user. Since there are no logs in ubuntu instance to check errors, i installed Sentry (Set it up manually) and Sentry is saying that the issue is a network error but is not showing the line responsible for that error. HELPPP ME !!!!
.env file
<code>NEXT_PUBLIC_API_URL=http://ec2-3-29-107-165.me-central-1.compute.amazonaws.com:3000
NEXTAUTH_URL = http://ec2-3-29-107-165.me-central-1.compute.amazonaws.com:3000
<code>NEXT_PUBLIC_API_URL=http://ec2-3-29-107-165.me-central-1.compute.amazonaws.com:3000
NEXTAUTH_URL = http://ec2-3-29-107-165.me-central-1.compute.amazonaws.com:3000
</code>
NEXT_PUBLIC_API_URL=http://ec2-3-29-107-165.me-central-1.compute.amazonaws.com:3000
NEXTAUTH_URL = http://ec2-3-29-107-165.me-central-1.compute.amazonaws.com:3000
There are other variables but i will not post them here.
Docker File:
<code>FROM node:18-alpine AS base
RUN apk add --no-cache libc6-compat
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
if [ -f yarn.lock ]; then yarn --frozen-lockfile;
elif [ -f package-lock.json ]; then npm ci;
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile;
else echo "Lockfile not found." && exit 1;
COPY --from=deps /app/node_modules ./node_modules
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
RUN chown nextjs:nodejs .next
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
CMD ["node", "server.js"]
<code>FROM node:18-alpine AS base
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN
if [ -f yarn.lock ]; then yarn --frozen-lockfile;
elif [ -f package-lock.json ]; then npm ci;
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile;
else echo "Lockfile not found." && exit 1;
fi
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
RUN mkdir .next
RUN chown nextjs:nodejs .next
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]
</code>
FROM node:18-alpine AS base
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN
if [ -f yarn.lock ]; then yarn --frozen-lockfile;
elif [ -f package-lock.json ]; then npm ci;
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile;
else echo "Lockfile not found." && exit 1;
fi
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
RUN mkdir .next
RUN chown nextjs:nodejs .next
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]