Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dockerfiles
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Picasoft
Technique
Dockerfiles
Commits
bdf82b78
Verified
Commit
bdf82b78
authored
4 years ago
by
Romain De Laage De Bellefaye
Browse files
Options
Downloads
Patches
Plain Diff
[CodiMD] Add a script to delete pads
parent
c6d84cd0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pica-codimd/Dockerfile
+5
-2
5 additions, 2 deletions
pica-codimd/Dockerfile
pica-codimd/deleteOldPad.py
+41
-0
41 additions, 0 deletions
pica-codimd/deleteOldPad.py
pica-codimd/docker-compose.yml
+3
-0
3 additions, 0 deletions
pica-codimd/docker-compose.yml
with
49 additions
and
2 deletions
pica-codimd/Dockerfile
+
5
−
2
View file @
bdf82b78
...
...
@@ -23,10 +23,11 @@ RUN addgroup --gid 5010 codimd && \
adduser
-u
5010
-G
codimd
-D
codimd
&&
\
mkdir
/home/
$USER_NAME
/.npm
&&
\
echo
"prefix=/home/codimd/.npm/"
>
/home/
$USER_NAME
/.npmrc
&&
\
mkdir
-p
/home/codimd/app
&&
\
mkdir
-p
/home/codimd/app
/deletedPads
&&
\
chown
-R
codimd:codimd /home/codimd
&&
\
# Git needed so NPM can clone packages and Python for node-gyp
apk add --no-cache bash git python && \
apk add --no-cache bash git python3-dev py3-pip gcc postgresql-dev musl-dev && \
pip3 install psycopg2 && \
wget https://github.com/hackmdio/portchecker/releases/download/${PORTCHECKER_VERSION}/portchecker-linux-amd64.tar.gz && \
tar xvf portchecker-linux-amd64.tar.gz -C /usr/local/bin && \
mv /usr/local/bin/portchecker-linux-amd64 /usr/local/bin/pcheck && \
...
...
@@ -38,6 +39,8 @@ WORKDIR /home/codimd/app
COPY
--chown=5010:5010 --from=BUILD /opt/codimd .
COPY
--chown=5010:5010 deleteOldPad.py .
RUN
npm
install
--production
&&
npm cache clean
--force
&&
rm
-rf
/tmp/
{
core-js-banners,phantomjs
}
COPY
entrypoint.sh .
...
...
This diff is collapsed.
Click to expand it.
pica-codimd/deleteOldPad.py
0 → 100755
+
41
−
0
View file @
bdf82b78
#! /usr/bin/python3
import
psycopg2
import
sys
from
os
import
environ
INTERVAL
=
environ
[
'
OLD_INTERVAL
'
]
USER
=
environ
[
'
POSTGRES_USER
'
]
DATABASE
=
environ
[
'
POSTGRES_DB
'
]
PASSWORD
=
environ
[
'
POSTGRES_PASSWORD
'
]
HOST
=
[
'
DB_HOST
'
]
PORT
=
[
'
DB_PORT
'
]
print
(
"
===== Begin of deleteOldPad job =====
"
)
try
:
db
=
psycopg2
.
connect
(
"
user =
"
+
USER
+
"
dbname =
"
+
DATABASE
+
"
password =
"
+
PASSWORD
+
"
host =
"
+
HOST
+
"
port =
"
+
PORT
)
except
:
sys
.
exit
(
"
deleteOldPad : Unable to connect database
"
)
with
db
:
with
db
.
cursor
()
as
cur
:
#Make a backup of old pads in deletedPads
try
:
cur
.
execute
(
"
SELECT
\"
Notes
\"
.
\"
id
\"
,
\"
Notes
\"
.
\"
content
\"
FROM
\"
Notes
\"
WHERE
\"
Notes
\"
.
\"
updatedAt
\"
< NOW() - interval %s
"
,
(
INTERVAL
,))
except
:
sys
.
exit
(
"
deleteOldPad : unable to select old pads
"
)
for
oldPad
in
cur
.
fetchall
():
with
open
(
"
deletedPads/
"
+
oldPad
[
0
]
+
'
.txt
'
,
"
w
"
)
as
f
:
f
.
write
(
oldPad
[
1
])
#Delete the old pads
try
:
cur
.
execute
(
"
DELETE FROM
\"
Notes
\"
WHERE
\"
Notes
\"
.
\"
updatedAt
\"
< NOW() - interval %s
"
,
(
INTERVAL
,))
except
:
sys
.
exit
(
"
deleteOldPad: unable to delete old pads
"
)
print
(
"
deleteOldPad : Deleted old pad
"
)
db
.
close
()
print
(
"
===== End of deleteOldPad job =====
"
)
This diff is collapsed.
Click to expand it.
pica-codimd/docker-compose.yml
+
3
−
0
View file @
bdf82b78
...
...
@@ -46,6 +46,9 @@ services:
CMD_CSP_ENABLE
:
"
false"
CMD_MATTERMOST_BASEURL
:
https://team.picasoft.net
CMD_DEFAULT_PERMISSION
:
freely
OLD_INTERVAL
:
"
2
years"
DB_HOST
:
"
codimd-db"
DB_PORT
:
5432
networks
:
-
proxy
-
codimd
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment