Aws deploy springboot project with error 502 - amazon-web-services

I am deploying the web app in aws elastic bean .The code run fine in localhost but fail with error 502.
Here are my log in eb with warn:
2022/11/12 18:05:10.175659 [INFO] Cleaned ebextensions subdirectories from app staging directory.
2022/11/12 18:05:10.175664 [INFO] Executing instruction: RunAppDeployPreDeployHooks
2022/11/12 18:05:10.175694 [INFO] Running command /bin/sh -c uname -m
2022/11/12 18:05:10.177374 [INFO] x86_64
2022/11/12 18:05:10.177397 [INFO] Executing platform hooks in .platform/hooks/predeploy/
2022/11/12 18:05:10.177417 [INFO] The dir .platform/hooks/predeploy/ does not exist
2022/11/12 18:05:10.177421 [INFO] Finished running scripts in /var/app/staging/.platform/hooks/predeploy
2022/11/12 18:05:10.177428 [INFO] Executing instruction: stop X-Ray
2022/11/12 18:05:10.177433 [INFO] stop X-Ray ...
2022/11/12 18:05:10.177442 [INFO] Running command /bin/sh -c systemctl show -p PartOf xray.service
2022/11/12 18:05:10.315088 [WARN] stopProcess Warning: process xray is not registered
2022/11/12 18:05:10.315115 [INFO] Running command /bin/sh -c systemctl stop xray.service
2022/11/12 18:05:10.323680 [INFO] Executing instruction: stop proxy
2022/11/12 18:05:10.323699 [INFO] Running command /bin/sh -c systemctl show -p PartOf httpd.service
2022/11/12 18:05:10.327933 [WARN] deregisterProcess Warning: process httpd is not registered, skipping...
2022/11/12 18:05:10.327948 [INFO] Running command /bin/sh -c systemctl show -p PartOf nginx.service
2022/11/12 18:05:10.334136 [WARN] deregisterProcess Warning: process nginx is not registered, skipping...
2022/11/12 18:05:10.334149 [INFO] Executing instruction: FlipApplication
2022/11/12 18:05:10.334154 [INFO] Fetching environment variables...
2022/11/12 18:05:10.334172 [INFO] Running command /bin/sh -c uname -m
2022/11/12 18:05:10.335672 [INFO] x86_64
2022/11/12 18:05:10.335768 [INFO] Purge old process...
2022/11/12 18:05:10.335786 [INFO] Removing /var/app/current/ if it exists
2022/11/12 18:05:10.335796 [INFO] Renaming /var/app/staging/ to /var/app/current/
2022/11/12 18:05:10.335811 [INFO] Register application processes...
2022/11/12 18:05:10.335818 [INFO] Registering the proc: web
Here are the log with error:
2022/11/12 18:18:19 [error] 3971#3971: *1 connect() failed (111: Connection refused) while connecting to upstream,

Related

Deploying Dockerized NextJs Application to AWS Elastic Beanstalk Throws 502 Bad Gateway

I am able to build and run my nextjs application locally with docker-compose, everything works fine. But when I deploy to Elastic Beanstalk, I get successful deployment but when I go to the url of the environment I get 502 Bad Gateway.
I've tried many different things, multiple different templates I have found online for the Dockerfile and docker-compose.yml. I've been able to run locally in many different ways but none of them work on elastic beanstalk.
If anyone has any insight I would appreciate it. Also I know the 100 lines of logs is a bit much down below but I thought any guidance might help for a faster resolution.
Important files below, and also here is the full repo -> https://github.com/mphbo/logan-thomas-production
Here is my Dockerfile:
# Install dependencies only when needed
FROM node:16-alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
# COPY package.json yarn.lock ./
# RUN yarn install --frozen-lockfile
# If using npm with a `package-lock.json` comment out above and use below instead
# AWS seems to have issues with old package-lock files, I have not included so that it is created on build
COPY package.json .
RUN npm i
# Rebuild the source code only when needed
FROM node:16-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/package-lock.json ./package-lock.json
COPY . .
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED 1
# RUN yarn build
# If using npm comment out above and use below instead
RUN npm run build
# Production image, copy all the files and run next
FROM node:16-alpine AS runner
WORKDIR /app
ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# You only need to copy next.config.js if you are NOT using the default configuration
# COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
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
CMD ["node", "server.js"]
And here is my docker-compose.yml
version: "3"
services:
web:
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000"
Also here are some of the last 100 lines of the logs from my most recent build. Had to remove most for size requirements from stack overflow.
----------------------------------------
/var/log/nginx/error.log
----------------------------------------
----------------------------------------
/var/log/eb-docker/containers/eb-current-app/eb-stdouterr.log
----------------------------------------
Attaching to current_web_1
web_1 | info - Loaded env from /app/.env
web_1 | Listening on port 3000
----------------------------------------
/var/log/docker-events.log
----------------------------------------
2022-03-17T03:20:54.704808186Z container destroy 9dfce132adf4411cb21998b4b680a8bd6cd460d85eb5df91886b244d3f4db330 (image=sha256:e3b21b7beaf5e68b05f3baca37d7b4fbcb114ba6d21f3bc890e45cd7384b8ba7, name=quizzical_leavitt)
2022-03-17T03:20:54.721955363Z container create ba23c18a0a8d82d2c1415b17f7ddf3c789ceac4dc4b145fa407d1897441a8822 (image=sha256:4d7510d46ddf6b2f523595a76270d9b99a00751e21b69560592fea60de9c5ec8, name=modest_morse)
2022-03-17T03:20:54.811489936Z container destroy ba23c18a0a8d82d2c1415b17f7ddf3c789ceac4dc4b145fa407d1897441a8822 (image=sha256:4d7510d46ddf6b2f523595a76270d9b99a00751e21b69560592fea60de9c5ec8, name=modest_morse)
2022-03-17T03:20:54.818358483Z image tag sha256:cdc27002fa166b55f0e0f17a258e8064ed8563b92d9d541d3483f3e4c5d7a525 (name=staging_web:latest)
2022-03-17T03:20:59.655258896Z container kill 5ebaa6c044e5484217d3c86c526d16ec52060590eb7b0751dbc8ada2ffce7f54 (com.docker.compose.config-hash=bb2863a542c107f09564fc88d62b338c563b5de443e0dc4e7a788ffcd8d342ad, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=current, com.docker.compose.project.config_files=docker-compose.yml, com.docker.compose.project.working_dir=/var/app/current, com.docker.compose.service=web, com.docker.compose.version=1.29.2, image=current_web, name=current_web_1, signal=15)
2022-03-17T03:20:59.675186211Z container die 5ebaa6c044e5484217d3c86c526d16ec52060590eb7b0751dbc8ada2ffce7f54 (com.docker.compose.config-hash=bb2863a542c107f09564fc88d62b338c563b5de443e0dc4e7a788ffcd8d342ad, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=current, com.docker.compose.project.config_files=docker-compose.yml, com.docker.compose.project.working_dir=/var/app/current, com.docker.compose.service=web, com.docker.compose.version=1.29.2, exitCode=0, image=current_web, name=current_web_1)
2022-03-17T03:20:59.755111992Z network disconnect c00f61c330f9ce4f2664214e5e99f8420b224e0cfe8c24ef90d30eef70653510 (container=5ebaa6c044e5484217d3c86c526d16ec52060590eb7b0751dbc8ada2ffce7f54, name=current_default, type=bridge)
2022-03-17T03:20:59.764733369Z container stop 5ebaa6c044e5484217d3c86c526d16ec52060590eb7b0751dbc8ada2ffce7f54 (com.docker.compose.config-hash=bb2863a542c107f09564fc88d62b338c563b5de443e0dc4e7a788ffcd8d342ad, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=current, com.docker.compose.project.config_files=docker-compose.yml, com.docker.compose.project.working_dir=/var/app/current, com.docker.compose.service=web, com.docker.compose.version=1.29.2, image=current_web, name=current_web_1)
2022-03-17T03:20:59.788410889Z container destroy 5ebaa6c044e5484217d3c86c526d16ec52060590eb7b0751dbc8ada2ffce7f54 (com.docker.compose.config-hash=bb2863a542c107f09564fc88d62b338c563b5de443e0dc4e7a788ffcd8d342ad, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=current, com.docker.compose.project.config_files=docker-compose.yml, com.docker.compose.project.working_dir=/var/app/current, com.docker.compose.service=web, com.docker.compose.version=1.29.2, image=current_web, name=current_web_1)
2022-03-17T03:20:59.836566662Z network destroy c00f61c330f9ce4f2664214e5e99f8420b224e0cfe8c24ef90d30eef70653510 (name=current_default,
----------------------------------------
/var/log/eb-docker-process.log
----------------------------------------
2022/03/16 00:56:29.964855 [INFO] Loading Manifest...
2022/03/16 00:56:29.964950 [INFO] no eb envtier info file found, skip loading env tier info.
2022/03/16 00:56:29.981151 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:us-east-1:080740215952:stack/awseb-e-xp7qsktpsk-stack/733824c0-a4c3-11ec-8cd3-0ebb713b3873 -r AWSEBAutoScalingGroup --region us-east-1
2022/03/16 00:56:30.757661 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:us-east-1:080740215952:stack/awseb-e-xp7qsktpsk-stack/733824c0-a4c3-11ec-8cd3-0ebb713b3873 -r AWSEBBeanstalkMetadata --region us-east-1
2022/03/16 00:56:31.224117 [INFO] Checking if docker is running...
2022/03/16 00:56:31.224134 [INFO] Fetch current app container id...
2022/03/16 00:56:31.224156 [INFO] Running command /bin/sh -c docker ps | grep 175915dc5ee7
2022/03/16 00:56:31.264646 [INFO] 175915dc5ee7 2517f92be235 "python /tmp/applica…" 8 seconds ago Up 7 seconds 8000/tcp focused_hypatia
2022/03/16 00:56:31.264686 [INFO] Running command /bin/sh -c docker wait 175915dc5ee7
----------------------------------------
/var/log/docker-compose-events.log
----------------------------------------
2022-03-16 04:55:49.722213 container create ccf18ec9402847bc1f635abbc26f3effae8d6d4aac609fd885fbcc72b024637a (image=current_web, name=current_web_1)
2022-03-16 04:55:50.459344 container start ccf18ec9402847bc1f635abbc26f3effae8d6d4aac609fd885fbcc72b024637a (image=current_web, name=current_web_1)
2022-03-16 05:28:02.520420 container create d40272c0074c0b6e1ab4859c402f73cd4d3d1ce75c8d7373eddf68f74726bfa4 (image=current_web, name=current_web_1)
2022-03-16 05:28:03.240080 container start d40272c0074c0b6e1ab4859c402f73cd4d3d1ce75c8d7373eddf68f74726bfa4 (image=current_web, name=current_web_1)
2022-03-16 05:43:21.269955 container create 6427b013979c0da82e636ca1022887fe7bde12977ed921f296d71f03d1b18e3d (image=current_web, maintainer=NGINX Docker Maintainers <docker-maint#nginx.com>, name=current_web_1)
2022-03-16 05:43:21.909654 container start 6427b013979c0da82e636ca1022887fe7bde12977ed921f296d71f03d1b18e3d (image=current_web, maintainer=NGINX Docker Maintainers <docker-maint#nginx.com>, name=current_web_1)
2022-03-16 05:43:21.943149 container die 6427b013979c0da82e636ca1022887fe7bde12977ed921f296d71f03d1b18e3d (exitCode=127, image=current_web, maintainer=NGINX Docker Maintainers <docker-maint#nginx.com>, name=current_web_1)
2022-03-16 05:43:23.650946 container destroy 6427b013979c0da82e636ca1022887fe7bde12977ed921f296d71f03d1b18e3d (image=current_web, maintainer=NGINX Docker Maintainers <docker-maint#nginx.com>, name=current_web_1)
2022-03-17 02:05:43.050073 container create b8fbe93e240c9023b7d4351cd1b65fb4ead54206cf28fb9e7cc58b89f2457619 (image=current_web, maintainer=NGINX Docker Maintainers <docker-maint#nginx.com>, name=current_web_1)
2022-03-17 02:05:43.703614 container start b8fbe93e240c9023b7d4351cd1b65fb4ead54206cf28fb9e7cc58b89f2457619 (image=current_web, maintainer=NGINX Docker Maintainers <docker-maint#nginx.com>, name=current_web_1)
2022-03-17 03:15:25.417627 container create 5ebaa6c044e5484217d3c86c526d16ec52060590eb7b0751dbc8ada2ffce7f54 (image=current_web, name=current_web_1)
2022-03-17 03:15:26.022821 container start 5ebaa6c044e5484217d3c86c526d16ec52060590eb7b0751dbc8ada2ffce7f54 (image=current_web, name=current_web_1)
2022-03-17 03:21:01.472006 container create 9a99c07fd6c6629ff92da05bc71692075a1ac0bf7a79d25e613eacf5cb9553c7 (image=current_web, name=current_web_1)
2022-03-17 03:21:02.081385 container start 9a99c07fd6c6629ff92da05bc71692075a1ac0bf7a79d25e613eacf5cb9553c7 (image=current_web, name=current_web_1)
2022-03-17 18:03:09.231168 container create 466ad0e8612ca55ba04307739873bff518d989d60ee02ba47fbfa868586cf7a3 (image=current_web, name=current_web_1)
2022-03-17 18:03:09.812741 container start 466ad0e8612ca55ba04307739873bff518d989d60ee02ba47fbfa868586cf7a3 (image=current_web, name=current_web_1)
----------------------------------------
/var/log/docker
----------------------------------------
Mar 16 00:54:30 ip-172-31-4-118 docker: time="2022-03-16T00:54:30.393689697Z" level=info msg="Starting up"
Mar 16 00:54:30 ip-172-31-4-118 docker: time="2022-03-16T00:54:30.409736448Z" level=info msg="parsed scheme: \"unix\"" module=grpc
Mar 16 00:54:30 ip-172-31-4-118 docker: time="2022-03-16T00:54:30.409762244Z" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
Mar 16 00:54:30 ip-172-31-4-118 docker: time="2022-03-16T00:54:30.409794007Z" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock <nil> 0 <nil>}] <nil> <nil>}" module=grpc
Mar 16 00:54:30 ip-172-31-4-118 docker: time="2022-03-16T00:54:30.409808870Z" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
Mar 16 00:54:30 ip-172-31-4-118 docker: time="2022-03-16T00:54:30.431080302Z" level=info msg="parsed scheme: \"unix\"" module=grpc
Mar 16 00:54:30 ip-172-31-4-118 docker: time="2022-03-16T00:54:30.431104184Z" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
Mar 16 00:54:30 ip-172-31-4-118 docker: time="2022-03-16T00:54:30.431124156Z" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock <nil> 0 <nil>}] <nil> <nil>}" module=grpc
Mar 16 00:54:30 ip-172-31-4-118 docker: time="2022-03-16T00:54:30.431135443Z" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
Mar 16 00:54:30 ip-172-31-4-118 docker: time="2022-03-16T00:54:30.625879192Z" level=info msg="Loading containers: start."
Mar 16 00:54:31 ip-172-31-4-118 docker: time="2022-03-16T00:54:31.162175982Z" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
Mar 16 00:54:31 ip-172-31-4-118 docker: time="2022-03-16T00:54:31.291890951Z" level=info msg="Loading containers: done."
Mar 16 00:54:31 ip-172-31-4-118 docker: time="2022-03-16T00:54:31.578800386Z" level=info msg="Docker daemon" commit=b0f5bc3 graphdriver(s)=overlay2 version=20.10.7
Mar 16 00:54:31 ip-172-31-4-118 docker: time="2022-03-16T00:54:31.579749223Z" level=info msg="Daemon has completed initialization"
Mar 16 00:54:31 ip-172-31-4-118 docker: time="2022-03-16T00:54:31.605571872Z" level=info msg="API listen on /run/docker.sock"
Mar 16 00:56:21 ip-172-31-4-118 docker: time="2022-03-16T00:56:21.102008961Z" level=info msg="Layer sha256:764fa8ef33a160d2a5c2bd412220c846a8a586bf966e03d6ea04f01c5524c219 cleaned up"
Mar 16 00:56:21 ip-172-31-4-118 docker: time="2022-03-16T00:56:21.220730612Z" level=info msg="Layer sha256:764fa8ef33a160d2a5c2bd412220c846a8a586bf966e03d6ea04f01c5524c219 cleaned up"
Mar 16 02:01:57 ip-172-31-4-118 docker: time="2022-03-16T02:01:57.345559855Z" level=info msg="ignoring event" container=f37efcfa2861a94bd4589834f691cd1ac44db54513a7edc6291922310cb85e28 module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
Mar 16 02:02:38 ip-172-31-4-118 docker: time="2022-03-16T02:02:38.733711684Z" level=info msg="ignoring event" container=ad83de473f3447c452d68d482fe0828b521cd7029dd4952d061d5b706ffb644a module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
Mar 16 02:02:45 ip-172-31-4-118 docker: time="2022-03-16T02:02:45.150779851Z" level=info msg="Layer sha256:aad4e7071a27ac48a27bf0e78a7e1c06cf76968554d091929cc735a0a005c50e cleaned up"
Mar 16 02:10:26 ip-172-31-4-118 docker: time="2022-03-16T02:10:26.395144645Z" level=info msg="ignoring event" container=d78d3b1e4bb25e89fc217ec17a39dbe32afbf5b092782c48387e20e74eb5bff4 module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
Mar 16 02:11:06 ip-172-31-4-118 docker: time="2022-03-16T02:11:06.695819171Z" level=info msg="ignoring event" container=e714a6196094ad30b9bacbc56a154cadd171573ecf2ccfc003935a6bb3e173bf module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
Mar 16 02:11:12 ip-172-31-4-118 docker: time="2022-03-16T02:11:12.381263816Z" level=info msg="Layer sha256:aad4e7071a27ac48a27bf0e78a7e1c06cf76968554d091929cc735a0a005c50e cleaned up"
Mar 16 04:46:26 ip-172-31-4-118 docker: time="2022-03-16T04:46:26.034993236Z" level=info msg="ignoring event"
----------------------------------------
/var/log/eb-engine.log
----------------------------------------
2022/03/17 18:03:08.417529 [INFO] Running command /bin/sh -c docker-compose up -d
2022/03/17 18:03:09.961410 [INFO] Running command /bin/sh -c systemctl show -p PartOf eb-docker-compose-log.service
2022/03/17 18:03:09.970952 [INFO] Running command /bin/sh -c systemctl daemon-reload
2022/03/17 18:03:10.082890 [INFO] Running command /bin/sh -c systemctl reset-failed
2022/03/17 18:03:10.093958 [INFO] Running command /bin/sh -c systemctl enable eb-docker-compose-log.service
2022/03/17 18:03:10.214523 [INFO] Running command /bin/sh -c systemctl show -p PartOf eb-docker-compose-log.service
2022/03/17 18:03:10.224477 [INFO] Running command /bin/sh -c systemctl is-active eb-docker-compose-log.service
2022/03/17 18:03:10.234898 [INFO] Running command /bin/sh -c systemctl start eb-docker-compose-log.service
2022/03/17 18:03:10.327790 [INFO] Running command /bin/sh -c docker-compose ps -q
2022/03/17 18:03:11.528797 [INFO] 466ad0e8612ca55ba04307739873bff518d989d60ee02ba47fbfa868586cf7a3
2022/03/17 18:03:11.529329 [INFO] Executing instruction: Clean up Docker
2022/03/17 18:03:11.529347 [INFO] Running command /bin/sh -c docker ps -aq
2022/03/17 18:03:11.569500 [INFO] 466ad0e8612c
2022/03/17 18:03:11.569536 [INFO] Running command /bin/sh -c docker images | sed 1d
2022/03/17 18:03:11.616081 [INFO] current_web latest 619583f1d6ce 9 seconds ago 114MB
<none> <none> e571fa5f409b 10 seconds ago 360MB
<none> <none> 329affc64c2a About a minute ago 454MB
node 16-alpine 0e1547c0f4a4 5 weeks ago 110MB
node lts-alpine 0e1547c0f4a4 5 weeks ago 110MB
2022/03/17 18:03:11.616128 [INFO] save docker tag command: docker tag 0e1547c0f4a4 node:16-alpine
2022/03/17 18:03:11.616133 [INFO] save docker tag command: docker tag 0e1547c0f4a4 node:lts-alpine
2022/03/17 18:03:11.616144 [INFO] Running command /bin/sh -c docker rm `docker ps -aq`
2022/03/17 18:03:11.693698 [INFO] Running command /bin/sh -c docker rmi `docker images -aq`
2022/03/17 18:03:13.198494 [INFO] Deleted: sha256:e571fa5f409bbdedd55795e0c90a17e12635069c6c6eaec33c8e0b0e46f1b57f
Deleted: sha256:f4379e9f6e5670d36350d042c308bd559add51d613914cea76c1f7ba0a69281d
2022/03/17 18:03:13.198511 [INFO] restore docker image name with command: docker tag 619583f1d6ce current_web:latest
2022/03/17 18:03:13.198534 [INFO] Running command /bin/sh -c docker tag 619583f1d6ce current_web:latest
2022/03/17 18:03:13.258536 [INFO] restore docker image name with command: docker tag e571fa5f409b <none>:<none>
2022/03/17 18:03:13.258573 [INFO] Running command /bin/sh -c docker tag e571fa5f409b <none>:<none>
2022/03/17 18:03:13.260182 [INFO] restore docker image name with command: docker tag 329affc64c2a <none>:<none>
2022/03/17 18:03:13.260193 [INFO] Running command /bin/sh -c docker tag 329affc64c2a <none>:<none>
2022/03/17 18:03:13.261564 [INFO] restore docker image name with command: docker tag 0e1547c0f4a4 node:16-alpine
2022/03/17 18:03:13.261615 [INFO] Running command /bin/sh -c docker tag 0e1547c0f4a4 node:16-alpine
2022/03/17 18:03:13.307632 [INFO] restore docker image name with command: docker tag 0e1547c0f4a4 node:lts-alpine
2022/03/17 18:03:13.307671 [INFO] Running command /bin/sh -c docker tag 0e1547c0f4a4 node:lts-alpine
2022/03/17 18:03:13.357160 [INFO] Executing instruction: start X-Ray
2022/03/17 18:03:13.357177 [INFO] X-Ray is not enabled.
2022/03/17 18:03:13.357181 [INFO] Executing instruction: configureSqsd
2022/03/17 18:03:13.357201 [INFO] This is a web server environment instance, skip configure sqsd daemon ...
2022/03/17 18:03:13.357206 [INFO] Executing instruction: startSqsd
2022/03/17 18:03:13.357214 [INFO] This is a web server environment instance, skip start sqsd daemon ...
2022/03/17 18:03:13.357219 [INFO] Executing instruction: Track pids in healthd
2022/03/17 18:03:13.357223 [INFO] This is an enhanced health env...
2022/03/17 18:03:13.357237 [INFO] Running command /bin/sh -c systemctl show -p ConsistsOf aws-eb.target | cut -d= -f2
2022/03/17 18:03:13.363354 [INFO] eb-docker-compose-events.service docker.service eb-docker-compose-log.service eb-docker-events.service cfn-hup.service healthd.service
2022/03/17 18:03:13.363374 [INFO] Running command /bin/sh -c systemctl show -p ConsistsOf eb-app.target | cut -d= -f2
2022/03/17 18:03:13.369062 [INFO]
2022/03/17 18:03:13.369625 [INFO] Executing instruction: Configure Docker Container Logging
2022/03/17 18:03:13.372466 [INFO] Executing instruction: RunAppDeployPostDeployHooks
2022/03/17 18:03:13.372481 [INFO] Executing platform hooks in .platform/hooks/postdeploy/
2022/03/17 18:03:13.372495 [INFO] The dir .platform/hooks/postdeploy/ does not exist
2022/03/17 18:03:13.372501 [INFO] Executing cleanup logic
2022/03/17 18:03:13.373123 [INFO] CommandService Response: {"status":"SUCCESS","api_version":"1.0","results":[{"status":"SUCCESS","msg":"Engine execution has succeeded.","returncode":0,"events":[{"msg":"Instance deployment completed successfully.","timestamp":1647540193,"severity":"INFO"}]}]}
2022/03/17 18:03:13.373272 [INFO] Platform Engine finished execution on command: app-deploy
2022/03/17 18:03:43.354453 [INFO] Starting...
2022/03/17 18:03:43.354502 [INFO] Starting EBPlatform-PlatformEngine
2022/03/17 18:03:43.354542 [INFO] reading event message file
2022/03/17 18:03:43.356863 [INFO] no eb envtier info file found, skip loading env tier info.
2022/03/17 18:03:43.356974 [INFO] Engine received EB command cfn-hup-exec
2022/03/17 18:03:43.480863 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:us-east-1:080740215952:stack/awseb-e-xp7qsktpsk-stack/733824c0-a4c3-11ec-8cd3-0ebb713b3873 -r AWSEBAutoScalingGroup --region us-east-1
2022/03/17 18:03:43.811316 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:us-east-1:080740215952:stack/awseb-e-xp7qsktpsk-stack/733824c0-a4c3-11ec-8cd3-0ebb713b3873 -r AWSEBBeanstalkMetadata --region us-east-1
2022/03/17 18:03:44.136679 [INFO] checking whether command tail-log is applicable to this instance...
2022/03/17 18:03:44.136692 [INFO] this command is applicable to the instance, thus instance should execute command
2022/03/17 18:03:44.136697 [INFO] Engine command: (tail-log)
2022/03/17 18:03:44.137649 [INFO] Executing instruction: GetTailLogs
2022/03/17 18:03:44.137659 [INFO] Tail Logs...
2022/03/17 18:03:44.139172 [INFO] Running command /bin/sh -c tail -n 100 /var/log/nginx/error.log
2022/03/17 18:03:44.142190 [INFO] Running command /bin/sh -c tail -n 100 /var/log/eb-docker/containers/eb-current-app/eb-stdouterr.log
2022/03/17 18:03:44.143761 [INFO] Running command /bin/sh -c tail -n 100 /var/log/docker-events.log
2022/03/17 18:03:44.146376 [INFO] Running command /bin/sh -c tail -n 100 /var/log/eb-docker-process.log
2022/03/17 18:03:44.148615 [INFO] Running command /bin/sh -c tail -n 100 /var/log/docker-compose-events.log
2022/03/17 18:03:44.150308 [INFO] Running command /bin/sh -c tail -n 100 /var/log/docker
2022/03/17 18:03:44.152670 [INFO] Running command /bin/sh -c tail -n 100 /var/log/eb-engine.log
----------------------------------------
/var/log/eb-hooks.log
----------------------------------------
----------------------------------------
/var/log/nginx/access.log
----------------------------------------
172.31.11.179 - - [16/Mar/2022:04:43:23 +0000] "GET / HTTP/1.1" 200 1438 "-" "ELB-HealthChecker/2.0" "-"
I finally found the solution. After hours of debugging, changing the docker file and docker-compose, and searching online for an answer a coworker explained to me that port 80 needs to be exposed... not port 3000 as I have in the docker-compose file.

AWS Beanstalk "eb-docker" is not registered

I have a Docker-backed AWS Elastic Beanstalk application. I pull the image from a private AWS ECR.
However, I get the "Instance deployment failed..." error. In the logs, I see
2021/12/08 21:57:49.261047 [INFO] Executing instruction: RestartAppServer
2021/12/08 21:57:49.261050 [INFO] Restarting customer application...
2021/12/08 21:57:49.261065 [INFO] detected current app is not docker compose app
2021/12/08 21:57:49.261073 [INFO] Running command /bin/sh -c systemctl show -p PartOf eb-docker.service
2021/12/08 21:57:49.265842 [WARN] stopProcess Warning: process eb-docker is not registered > 2021/12/08 21:57:49.265859 [INFO] Running command /bin/sh -c systemctl stop eb-docker.service
2021/12/08 21:57:49.270477 [INFO] Running command /bin/sh -c systemctl show -p PartOf eb-docker.service
2021/12/08 21:57:49.275369 [ERROR] An error occurred during execution of command [restart-app-server] - [RestartAppServer]. Stop running the command. Error: startProcess Failure: process "eb-docker" is not registered
What do I do about this? How to register "eb-docker"?
My Dockerrun.aws.json is quite simple
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "**.dkr.ecr.eu-central-1.amazonaws.com/*:*",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "80"
}
]
}

Gunicorn working in Docker but not in AWS Beanstalk

My flask app is structured as
webapp
-- __init___.py (app and server are initialized here)
-- stuff.py
Dockerfile
entrypoint.sh
Dockerfile last line: ENTRYPOINT ["sh","./entrypoint.sh"]
Inside entrypoint.sh: gunicorn -w 1 --timeout 1800 --bind :80 webapp:server Also tried webapp.__init__:server, webapp:app.server, webapp:app
This works on docker with the following result:
[INFO] Starting gunicorn 20.1.0
[INFO] Listening at: http://0.0.0.0:80 (9)
[INFO] Using worker: sync
[INFO] Booting worker with pid: 11
but running on AWS beanstalk I get the follow:
[INFO] Starting gunicorn 20.1.0
[INFO] Listening at: http://0.0.0.0:80 (9)
[INFO] Using worker: sync
[INFO] Booting worker with pid: 11
Failed to find attribute 'server' in 'webapp'.
[INFO] Worker exiting (pid: 11)
[INFO] Shutting down: Master
[INFO] Reason: App failed to load.
server is inside webapp. Can gunicorn not handle __init__.py? But it works on local docker.

Getting error when trying to deploy spring boot + mysql app to AWS using codepipeline

I have build a cicd pipeline using AWS codepipeline.
Source is coming from Github which successed. Build is also successed.
I am using Corretto 11 running on 64bit Amazon Linux 2 as a platform in Elastic Beanstalk as Java 8 running on 64bit Amazon Linux shows as it's being deprecated.
I'm getting error during deployment to AWS Elastic Beanstalk.
Action execution failed
Deployment completed, but with errors: Failed to deploy application. Unsuccessful command execution on instance id(s) 'i-03b7a9c8a86ffde8e'. Aborting the operation. [Instance: i-03b7a9c8a86ffde8e] Command failed on instance. Return code: 1 Output: Engine execution has encountered an error.. Instance deployment failed. For details, see 'eb-engine.log'.
I checked eb-engine.log file and see below error message.
...
...
2021/11/07 05:01:18.765214 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /tmp/extracted_app_source_bundle
2021/11/07 05:01:18.765227 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /tmp/extracted_app_source_bundle
2021/11/07 05:01:19.122461 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /tmp/extracted_app_source_bundle successfully
2021/11/07 05:01:19.122560 [INFO] app source bundle is zip file ...
2021/11/07 05:01:19.122566 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/
2021/11/07 05:01:19.122578 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/
2021/11/07 05:01:19.498171 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/ successfully
2021/11/07 05:01:19.498694 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2021/11/07 05:01:19.498712 [INFO] The dir .platform/hooks/prebuild/ does not exist in the application. Skipping this step...
2021/11/07 05:01:19.498717 [INFO] Executing instruction: Java Specific Build Application
2021/11/07 05:01:19.498724 [INFO] no buildfile found, skip building java application
2021/11/07 05:01:19.498731 [INFO] old env file for build tasks does not exist
2021/11/07 05:01:19.498742 [INFO] Executing instruction: CheckProcfileForJavaApplication
2021/11/07 05:01:19.498776 [ERROR] An error occurred during execution of command [app-deploy] - [CheckProcfileForJavaApplication]. Stop running the command. Error: there is no Procfile and no .jar file at root level of your source bundle
2021/11/07 05:01:19.498786 [INFO] Executing cleanup logic
2021/11/07 05:01:19.498869 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1636261279,"severity":"ERROR"}]}]}
...
...
Below is my buildspec.yml file.
version: 0.2
phases:
install:
runtime-versions:
java: corretto11
commands:
- echo install
pre_build:
commands:
- echo pre_build
build:
commands:
- mvn package
- echo build
post_build:
commands:
- echo post_build
artifacts:
files:
- target/course_reviews_backend-0.0.1-SNAPSHOT.jar
PLEASE HELP!!
Any help would be appericated. Thanks in advance.

make.service fails when deploying Go project file to AWS Elastic Beanstalk

overflowers,
I've been struggling for hours on end trying to publish a Go application to AWS Elastic Beanstalk.
Have followed helpful tutorials online for what I first thought was dead simple.
One of the tutorials i followed
Another one of the tutorials i followed
An examples which actually compiles on AWS for me
My project structure is now:
The following files are all in my root folder:
application.go
build.sh
Buildfile
Procfile
application.go
package main
import (
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
router.GET("/user/:name", func(c *gin.Context) {
name := c.Param("name")
c.String(http.StatusOK, "Hello %s", name)
})
router.Run(":5000")
}
build.sh
go get "github.com/gin-gonic/gin" //Have tried without quotation marks
go build application.go
Buildfile
make: ./build.sh
Procfile
web: bin/application
I have also read the documentation on AWS website. And from what I can tell- my code, and the code in the demos referred to above, is correct.
I compress the enire contents of my root folder to a .zip file and upload to AWS through the web portal.
It fails...and in the error logs i can read:
2020/08/28 23:17:38.902079 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2020/08/28 23:17:38.902095 [INFO] The dir .platform/hooks/prebuild/ does not exist in the application. Skipping this step...
2020/08/28 23:17:38.902100 [INFO] Executing instruction: Golang Specific Build Application
2020/08/28 23:17:38.902104 [INFO] checking Buildfile...
2020/08/28 23:17:38.902110 [INFO] building Golang application with Buildfile
2020/08/28 23:17:38.902148 [INFO] Running command /bin/sh -c systemctl show -p PartOf make.service
2020/08/28 23:17:38.908345 [WARN] Warning: process make is already registered...
Deregistering the process ...
2020/08/28 23:17:38.908368 [INFO] Running command /bin/sh -c systemctl show -p PartOf make.service
2020/08/28 23:17:38.913626 [INFO] Running command /bin/sh -c systemctl is-active make.service
2020/08/28 23:17:38.916919 [INFO] Running command /bin/sh -c systemctl disable make.service
2020/08/28 23:17:39.002192 [INFO] Running command /bin/sh -c systemctl daemon-reload
2020/08/28 23:17:39.086778 [INFO] Running command /bin/sh -c systemctl reset-failed
2020/08/28 23:17:39.092606 [INFO] Running command /bin/sh -c systemctl daemon-reload
2020/08/28 23:17:39.166648 [INFO] Running command /bin/sh -c systemctl reset-failed
2020/08/28 23:17:39.170861 [INFO] Running command /bin/sh -c systemctl is-enabled eb-app.target
2020/08/28 23:17:39.174735 [INFO] Running command /bin/sh -c systemctl enable eb-app.target
2020/08/28 23:17:39.251327 [INFO] Running command /bin/sh -c systemctl start eb-app.target
2020/08/28 23:17:39.256334 [INFO] Running command /bin/sh -c systemctl enable make.service
2020/08/28 23:17:39.338502 [INFO] Running command /bin/sh -c systemctl show -p PartOf make.service
2020/08/28 23:17:39.344691 [INFO] Running command /bin/sh -c systemctl is-active make.service
2020/08/28 23:17:39.348280 [INFO] Running command /bin/sh -c systemctl start make.service
2020/08/28 23:17:39.358198 [ERROR] startProcess Failure: starting process "make" failed: Command /bin/sh -c systemctl start make.service failed with error exit status 1. Stderr:Job for make.service failed because the control process exited with error code. See "systemctl status make.service" and "journalctl -xe" for details.
2020/08/28 23:17:39.358222 [ERROR] An error occurred during execution of command [app-deploy] - [Golang Specific Build Application]. Stop running the command. Error: build application failed on command ./build.sh with error: startProcess Failure: starting process "make" failed: Command /bin/sh -c systemctl start make.service failed with error exit status 1. Stderr:Job for make.service failed because the control process exited with error code. See "systemctl status make.service" and "journalctl -xe" for details.
Unfortunately I don't have much experience of this kind of server configuration or any other deployment operations. So I do not understand "process make is already registered..."
...Perhaps someone more experienced in these areas might know what to make of this?
Cheers!
NOTE: The project has been able to compile and run on my computer all the time. It just fails when i try deploying it on the Elastic Beanstalk.
EDIT: Have now also tried deploying with the AWS Command Line Interface. In this case the logfile eb-activity tells me:
Executing: HOME=/tmp /opt/elasticbeanstalk/lib/ruby/bin/ruby /opt/elasticbeanstalk/lib/ruby/bin/foreman start --procfile /tmp/d20200829-3130-13cz1sh/eb-buildtask-0 --root /var/app/staging --env /var/elasticbeanstalk/staging/elasticbeanstalk.env
/opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.2.0/gems/foreman-0.78.0/lib/foreman/process.rb:54:in `spawn': Permission denied - ./build.sh (Errno::EACCES)
from /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.2.0/gems/foreman-0.78.0/lib/foreman/process.rb:54:in `block in run'
This may occur when the build.sh script lacks executable permissions. When that's the case "make.service" on beanstalk can't execute the script and an error is generated.
If you are developing on a unix machine try to chmod +x build.sh before deployment.
If you are developing on a windows machine you can't set the unix file attribute. But you can use this trick with Buildfile and deploy this way.
Buildfile
make: chmod +x build.sh; ./build.sh
This will make build.sh executable when the make service runs.
I also encountered this issue when migrating the deployment of my Golang application to the Amazon Linux 2 platform from Amazon Linux 1 platform. I was experiencing a similar error in the build process:
2021/07/10 16:33:21.411538 [ERROR] An error occurred during execution of command [app-deploy] - [Golang Specific Build Application]. Stop running the command. Error: build application failed on command ./build.sh with error: startProcess Failure: starting process "make" failed: Command /bin/sh -c systemctl start make.service failed with error exit status 1. Stderr:Job for make.service failed because the control process exited with error code. See "systemctl status make.service" and "journalctl -xe" for details.
After looking in to the systemctl status, as suggested in the error, I figured out the linux user "webapp" did not seem to have the correct permissions.
I added "webapp" to the sudoers file and now that build process finishes, and the deploy is able to succeed.
# User rules for webapp user
webapp ALL=(ALL) NOPASSWD:ALL