Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
console
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
console
Commits
b584639b
Commit
b584639b
authored
Aug 20, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zstd and dockerfile
parent
27362edb
Pipeline
#4769
failed with stages
in 4 minutes and 53 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
77 additions
and
27 deletions
+77
-27
.dockerignore
.dockerignore
+2
-0
.gitlab-ci.yml
.gitlab-ci.yml
+43
-0
Dockerfile
Dockerfile
+18
-13
console-api/package.json
console-api/package.json
+2
-2
console-api/src/app.controller.ts
console-api/src/app.controller.ts
+1
-1
console-api/src/app.service.ts
console-api/src/app.service.ts
+2
-2
console-api/src/entities/Archive.entity.ts
console-api/src/entities/Archive.entity.ts
+1
-1
console-api/src/main.ts
console-api/src/main.ts
+2
-2
console-api/src/packager/packager.service.ts
console-api/src/packager/packager.service.ts
+4
-4
console-api/views/metalinks.mustache
console-api/views/metalinks.mustache
+2
-2
No files found.
.dockerignore
0 → 100644
View file @
b584639b
/**/node_modules
/**/dist
.gitlab-ci.yml
0 → 100644
View file @
b584639b
stages
:
-
build
-
deploy
variables
:
GIT_DEPTH
:
"
1"
CONTAINER_TEST_IMAGE
:
$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
CONTAINER_RELEASE_IMAGE
:
$CI_REGISTRY_IMAGE:latest
before_script
:
-
docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
build
:
stage
:
build
tags
:
-
docker
script
:
-
docker build --pull -t $CONTAINER_TEST_IMAGE .
-
docker push $CONTAINER_TEST_IMAGE
deploy_latest
:
stage
:
deploy
tags
:
-
docker
script
:
-
docker pull $CONTAINER_TEST_IMAGE
-
docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
-
docker push $CONTAINER_RELEASE_IMAGE
only
:
-
master
deploy_tag
:
stage
:
deploy
tags
:
-
docker
variables
:
CONTAINER_TAG_IMAGE
:
$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
script
:
-
docker pull $CONTAINER_TEST_IMAGE
-
docker tag $CONTAINER_TEST_IMAGE $CONTAINER_TAG_IMAGE
-
docker push $CONTAINER_TAG_IMAGE
only
:
-
tags
Dockerfile
View file @
b584639b
FROM
node:16.3.0-alpine3.13 as web
#FROM node:16-bullseye-slim as web
#WORKDIR /app
#COPY console-web/package*.json ./
#RUN npm ci
#COPY console-web ./
#RUN npm run build
FROM
node:16-bullseye-slim as api-base
RUN
apt update
&&
\
apt
-y
install
build-essential python3 libpq-dev
tar
zstd
gzip
&&
\
rm
-rf
/var/lib/apt/lists/
*
/tmp/
*
/var/tmp/
*
WORKDIR
/app
COPY
console-web/package*.json ./
RUN
npm ci
COPY
console-web .
RUN
npm run build
COPY
console-api/package*.json ./
FROM
node:16.3.0-alpine3.13 as api
WORKDIR
/app
COPY
console-api
/package*.json
./
FROM
api-base as api
COPY
console-api ./
RUN
npm ci
COPY
console-api .
RUN
npm run build
FROM
node:16.3.0-alpine3.13
FROM
api-base
ENV
NODE_ENV=production
WORKDIR
/app
COPY
--from=api /app/package*.json ./
RUN
npm ci
COPY
--from=api /app/dist dist
COPY
--from=api /app/views views
COPY
--from=web /app/dist/console-web public
#COPY --from=web /app/dist/console-web public
ENV
NODE_PG_FORCE_NATIVE=true
EXPOSE
3000
CMD
["npm", "run", "start:prod"]
console-api/package.json
View file @
b584639b
...
...
@@ -44,13 +44,13 @@
"rimraf"
:
"^3.0.2"
,
"rxjs"
:
"^7.2.0"
,
"swagger-ui-express"
:
"^4.1.6"
,
"typeorm"
:
"^0.2.37"
"typeorm"
:
"^0.2.37"
,
"@nestjs/cli"
:
"^8.0.0"
},
"optionalDependencies"
:
{
"pg-native"
:
"^3.0.0"
},
"devDependencies"
:
{
"@nestjs/cli"
:
"^8.0.0"
,
"@nestjs/schematics"
:
"^8.0.0"
,
"@nestjs/testing"
:
"^8.0.0"
,
"@types/busboy"
:
"^0.2.4"
,
...
...
console-api/src/app.controller.ts
View file @
b584639b
...
...
@@ -112,7 +112,7 @@ export class AppController {
@
ApiParam
({
name
:
'
version
'
,
description
:
'
APP 的版本号
'
})
@
ApiQuery
({
type
:
DepotDto
,
description
:
'
APP 的类型
'
})
@
ApiBody
({
description
:
'
app 的 tar.
gz
文件
'
,
description
:
'
app 的 tar.
zst
文件
'
,
type
:
FileUploadDto
,
})
@
ApiCreatedResponse
({
type
:
BuildReturnMessageDto
})
...
...
console-api/src/app.service.ts
View file @
b584639b
...
...
@@ -235,7 +235,7 @@ export class AppService extends ConsoleLogger {
query
.
andWhere
(
`unusedBuild.id not in
${
subQuery
.
getQuery
()}
`
).
andWhere
(
`not exists
${
packageReferenceQuery
.
getQuery
()}
`
);
this
.
log
(
`SQL:
${
query
.
getQueryAndParameters
()}
`
);
return
(
await
query
.
getRawMany
()).
map
((
s
)
=>
`
${
s
.
pathToPurge
}
.tar.
gz
`
as
string
);
return
(
await
query
.
getRawMany
()).
map
((
s
)
=>
`
${
s
.
pathToPurge
}
.tar.
zst
`
as
string
);
}
private
async
getArchivePathsToPurge
(
buildId
:
number
)
{
...
...
@@ -247,7 +247,7 @@ export class AppService extends ConsoleLogger {
this
.
packageReferenceSubQuery
(
query
);
// this.log(`SQL: ${query.getQueryAndParameters()}`);
return
(
await
query
.
getRawMany
()).
map
((
s
)
=>
`
${
s
.
pathToPurge
}
.tar.
gz
`
as
string
);
return
(
await
query
.
getRawMany
()).
map
((
s
)
=>
`
${
s
.
pathToPurge
}
.tar.
zst
`
as
string
);
}
async
purgeOldArchives
()
{
...
...
console-api/src/entities/Archive.entity.ts
View file @
b584639b
...
...
@@ -31,7 +31,7 @@ export class Archive extends TimeBase {
role
:
ArchiveType
;
get
archiveFullPath
()
{
return
`
${
this
.
path
}
.tar.
gz
`
;
return
`
${
this
.
path
}
.tar.
zst
`
;
}
toMetalinkView
()
{
...
...
console-api/src/main.ts
View file @
b584639b
...
...
@@ -16,8 +16,8 @@ async function bootstrap() {
app
.
setViewEngine
(
'
mustache
'
);
const
documentConfig
=
new
DocumentBuilder
()
.
setTitle
(
'
app
'
)
.
setDescription
(
'
The app
'
)
.
setTitle
(
'
mycard-console-api
'
)
.
setDescription
(
'
萌卡 APP 更新发布后台
'
)
.
setVersion
(
'
1.0
'
)
.
addTag
(
'
admin
'
,
'
只有萌卡管理员可以用
'
)
.
addTag
(
'
update
'
,
'
萌卡客户端使用的
'
)
...
...
console-api/src/packager/packager.service.ts
View file @
b584639b
...
...
@@ -30,7 +30,7 @@ export class ArchiveTask {
}
get
archiveFullPath
()
{
return
`
${
this
.
path
}
.tar.
gz
`
;
return
`
${
this
.
path
}
.tar.
zst
`
;
}
get
filePaths
()
{
...
...
@@ -87,7 +87,7 @@ export class PackagerService extends ConsoleLogger {
this
.
log
(
`Extracting package to
${
extractRoot
}
.`
);
stream
.
resume
();
//stream.on('data', (data) => this.log(`data => ${data}`));
await
this
.
spawnAsync
(
'
tar
'
,
[
'
-
z
xf
'
,
'
-
'
],
{
cwd
:
extractRoot
},
stream
);
await
this
.
spawnAsync
(
'
tar
'
,
[
'
-
-zstd
'
,
'
-
xf
'
,
'
-
'
],
{
cwd
:
extractRoot
},
stream
);
this
.
log
(
`Package extracted to
${
extractRoot
}
.`
);
...
...
@@ -178,7 +178,7 @@ export class PackagerService extends ConsoleLogger {
const
files
=
archiveTask
.
filePaths
;
this
.
log
(
`Packaging archive
${
archiveName
}
with
${
files
.
length
}
files.`
);
const
stream
=
new
Stream
.
Writable
();
const
child
=
child_process
.
spawn
(
'
tar
'
,
[
'
-
zcv
f
'
,
'
-
'
].
concat
(
files
),
{
const
child
=
child_process
.
spawn
(
'
tar
'
,
[
'
-
-zstd
'
,
'
-c
f
'
,
'
-
'
].
concat
(
files
),
{
cwd
:
root
,
});
const
childPromise
=
new
Promise
<
void
>
((
resolve
,
reject
)
=>
{
...
...
@@ -194,7 +194,7 @@ export class PackagerService extends ConsoleLogger {
});
});
const
uploadPromise
=
this
.
s3
.
uploadStream
(
archiveName
,
child
.
stdout
,
{
ContentType
:
'
application/tar+
gzip
'
,
ContentType
:
'
application/tar+
zstd
'
,
});
const
[,
{
object
}]
=
await
Promise
.
all
([
childPromise
,
uploadPromise
]);
archive
.
size
=
object
.
Size
;
...
...
console-api/views/metalinks.mustache
View file @
b584639b
<?xml version="1.0" encoding="UTF-8"?>
<metalink
xmlns=
"urn:ietf:params:xml:ns:metalink"
>
{{#
archives
}}
<file
name=
"
{{
path
}}
.tar.
gz
"
>
<file
name=
"
{{
path
}}
.tar.
zst
"
>
<size>
{{
size
}}
</size>
<url
priority=
"1"
>
{{&
cdnUrl
}}
/
{{
path
}}
.tar.
gz
</url>
<url
priority=
"1"
>
{{&
cdnUrl
}}
/
{{
path
}}
.tar.
zst
</url>
</file>
{{/
archives
}}
</metalink>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment