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

feat(runtime): add feature support runing in docker env #1930

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

HUAHUAI23
Copy link
Contributor

No description provided.

HUAHUAI23 added 2 commits March 29, 2024 09:17
Copy link

vercel bot commented Mar 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
laf ❌ Failed (Inspect) Apr 1, 2024 4:18am

Copy link

cla-assistant bot commented Mar 29, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


HUAHUAI23 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
Copy link

cla-assistant bot commented Mar 29, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


HUAHUAI23 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

github-actions bot commented Mar 29, 2024

💥 laf nodejs runtime init image built successfully for pr 1930

ghcr.io/labring/runtime-node-init:pr-1930
docker.io/lafyun/runtime-node-init:pr-1930

digest: sha256:737740254ac08caf1ec9b72089361abfc1d7560a9f41cbec12964406673d6c70

Copy link

github-actions bot commented Mar 29, 2024

💥 laf nodejs runtime image built successfully for pr 1930

ghcr.io/labring/runtime-node:pr-1930
docker.io/lafyun/runtime-node:pr-1930

digest: sha256:2e66d703fd97fc7c9aeb7d5e26b397ae781638a905eb55882435369abed3b283

Copy link

github-actions bot commented Mar 29, 2024

💥 laf server image built successfully for pr 1930

ghcr.io/labring/laf-server:pr-1930
docker.io/lafyun/laf-server:pr-1930

digest: sha256:39e0f99c1128d6018116663cce388d218fbdfcd1459d4b675c5fa1bd4f9a94d7

HUAHUAI23 added 2 commits March 30, 2024 04:49
@HUAHUAI23 HUAHUAI23 changed the title feat(runtime): add feature run in docker env feat(runtime): add feature support runing in docker env Mar 30, 2024
HUAHUAI23 added 2 commits March 30, 2024 05:23
HUAHUAI23 added 3 commits March 30, 2024 05:41
@HUAHUAI23 HUAHUAI23 requested review from maslow and 0fatal April 1, 2024 02:42

await fs.mkdir(WORKSPACE_PATH, { recursive: true })

const funcs = await DatabaseAgent.db
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FunctionCache.getAll

await pipeline(readStream, res).then(() => {
// after pipe the file stream, remove the tar file
fsPromises.unlink(TAR_FILE_PATH).catch((unlinkError) => {
console.error('Error removing file:', unlinkError)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.error

)
}

// /docker-file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

res: Response,
) {
try {
// Save them to the workspace directory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上下注释的大小写对齐

try {
await fs.rm(WORKSPACE_PATH, { recursive: true, force: true })
} catch (err) {
console.error('Error removing the workspace directory:', err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是错误

}

for (const [key, value] of Object.entries(ENV)) {
if (keysToInclude.includes(key)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

放到上面的conf.environments

envVariablesString = envVariablesString.replace(/\\\n\s*$/, '')

// version from env todo
const DOCKER_FILE = `
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DOCKERFILE

export async function handleDockerFile(_: IRequest, res: Response) {
try {
const ENV = process.env
const keysToInclude = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

去掉不需要的

USER node
RUN npm install ${ENV.DEPENDENCIES} || true

RUN curl -o /tmp/cloud_functions.tar https://${ENV.RUNTIME_DOMAIN}/_/${process.env.SERVER_SECRET}/cloud_functions/tar && tar -xf /tmp/cloud_functions.tar -C /app/cloud_functions && rm /tmp/cloud_functions.tar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${process.env.SERVER_SECRET} 放在 tar后面,最好用jwt

USER node
RUN npm install ${ENV.DEPENDENCIES} || true

RUN curl -o /tmp/cloud_functions.tar https://${ENV.RUNTIME_DOMAIN}/_/${process.env.SERVER_SECRET}/cloud_functions/tar && tar -xf /tmp/cloud_functions.tar -C /app/cloud_functions && rm /tmp/cloud_functions.tar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http的兼容

@maslow
Copy link
Member

maslow commented Apr 7, 2024

这个 pr 先不合, 等一起讨论后再决定

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants