Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleaned up multi-service compose #75

Merged
merged 11 commits into from Apr 13, 2022
Merged

Conversation

kinghat
Copy link
Contributor

@kinghat kinghat commented Apr 7, 2022

this is carryover from: #13

gets the images built and containers running for both server and client. there is a server build issue in builder because it cant find .env:

Step 13/24 : RUN yarn build
---> Running in ef5ee9eca9ee
yarn run v1.22.18
$ mkdir -p ./dist && cp .env ./dist/.env && tsc -p ./tsconfig.json && tsc-alias -p ./tsconfig.json && yarn post-build
cp: can't stat '.env': No such file or directory
error Command failed with exit code 1.

explicitly giving the image a duplicated .env.test -> .env allows the build to complete and create container. there is another issue that i ran into when loading the client at http://localhost:3001/:

Something went wrong. Is the server running?

and when navigating to: http://localhost:3001/signup

client | Error: connect ECONNREFUSED 127.0.0.1:3000
client | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16) {
client | errno: -111,
client | code: 'ECONNREFUSED',
client | syscall: 'connect',
client | address: '127.0.0.1',
client | port: 3000
client | }

viewing the server health at: http://localhost:3000/health

status: "UP"

@MaxLeiter
Copy link
Owner

  1. Can you add a yarn build:docker to address the .env issue? You can create a .env.docker if it's necessary
  2. Error: connect ECONNREFUSED seems like a networking issue. is API_URL set for the client?

@kinghat
Copy link
Contributor Author

kinghat commented Apr 12, 2022

everything should be address from: #75 (comment)

client/Dockerfile Outdated Show resolved Hide resolved
docker-compose.yml Outdated Show resolved Hide resolved
@MaxLeiter
Copy link
Owner

@reeseovine can you test this and confirm jt works as expected? 🙏

@reeseovine
Copy link
Contributor

reeseovine commented Apr 13, 2022

Does the server still need to be up before the client can build? I'm getting this error on the client which doesn't seem related:

Step 13/28 : RUN yarn build
 ---> Running in 5ac5bd5ab544
yarn run v1.22.18
$ next build
warn  - You have enabled experimental feature(s).
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.

info  - Checking validity of types...
Failed to compile.

./components/admin/index.tsx:6:23
Type error: Cannot find module './post-modal-link' or its corresponding type declarations.

  4 | import { useEffect, useMemo, useState } from "react"
  5 | import styles from "./admin.module.css"
> 6 | import PostModal from "./post-modal-link"
    |                       ^
  7 | import PostTable from "./post-table"
  8 | import UserTable from "./user-table"
  9 | 
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The command '/bin/sh -c yarn build' returned a non-zero code: 1
ERROR: Service 'client' failed to build : Build failed

@reeseovine
Copy link
Contributor

Wait, I'm dumb lol. I was on the wrong branch.

But now I get this error when building the server:

Step 2/25 : RUN apk add --no-cache libc6-compat git
 ---> Running in 9111feaac514
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.15/main: temporary error (try again later)
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.15/community: temporary error (try again later)
ERROR: unable to select packages:
  git (no such package):
    required by: world[git]
  libc6-compat (no such package):
    required by: world[libc6-compat]
The command '/bin/sh -c apk add --no-cache libc6-compat git' returned a non-zero code: 2
ERROR: Service 'server' failed to build : Build failed

@reeseovine
Copy link
Contributor

Sorry for the spam... It's been a while. I've run into that issue before and just needed to add network: host to the build section of both services in the compose file.

...buuuuuut now we're back to the first issue:

 ---> Running in 52753813e5d7
yarn run v1.22.18
$ next build
warn  - You have enabled experimental feature(s).
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.

info  - Checking validity of types...
Failed to compile.

./components/admin/index.tsx:6:23
Type error: Cannot find module './post-modal-link' or its corresponding type declarations.

  4 | import { useEffect, useMemo, useState } from "react"
  5 | import styles from "./admin.module.css"
> 6 | import PostModal from "./post-modal-link"
    |                       ^
  7 | import PostTable from "./post-table"
  8 | import UserTable from "./user-table"
  9 | 
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The command '/bin/sh -c yarn build' returned a non-zero code: 1
ERROR: Service 'client' failed to build : Build failed

@MaxLeiter
Copy link
Owner

No, the server isn't required to be running anymore for the client -- it was too difficult to figure out the docker setup.

And that import error is my fault, I was rushing. You should be able to just remove that line; I'll push a fix soon.

@reeseovine
Copy link
Contributor

Ok cool, it works now! Even got it up on my server behind nginx proxy manager.

@kinghat
Copy link
Contributor Author

kinghat commented Apr 13, 2022

branch should be up to date now.

@MaxLeiter
Copy link
Owner

👏 LGTM

@MaxLeiter MaxLeiter merged commit 43aa68e into MaxLeiter:main Apr 13, 2022
@kinghat kinghat deleted the container-config branch April 14, 2022 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants