Comments (14)
@buhman version creates layer with buld deps. combine apk add
+ apk del
to same RUN
statement, or use multi stage builds.
FROM python:3.6-alpine
WORKDIR /pb
RUN set -x \
&& apk add --no-cache --virtual .build-deps git \
&& git clone https://github.com/ptpb/pb /build \
&& pip install /build \
&& apk del .build-deps
CMD ["python", "-m", "pb"]
FROM python:3.6-alpine
RUN apk add --no-cache git
RUN git clone https://github.com/ptpb/pb /build
RUN pip install /build
FROM python:3.6-alpine
COPY --from=0 /usr/local /usr/local
CMD ["python", "-m", "pb"]
the multi stage may have other dependencies you may need to copy, so it's not safest to have. you need to verify outcome with every change.
from pb.
However, I'm not finding any way to go to back to the terminal to execute commands
There are several possible answers to this question.
- If you want to re-use the same terminal for (local) commands, you can background docker-compose with
docker-compose up --detach
. - If you want to execute a command in a running container's context, you can use
docker exec
. List running containers withdocker ps
, and run a shell inside, say, the pb app container withdocker exec -ti pb_pb_1 /bin/sh
(this also matches the name shown on the left column ofdocker-compose run
output.
If this doesn't answer your question, please clarify which commands you're interested in running.
In mongodb or unix file system?
Never on the filesystem. Pastes are stored entirely mongodb (both metadata and content), sometimes via GridFS. My original idea was mongo offers reasonably good horizontal scaling and sharding out of the box, so these properties would apply to pb as well. If I were to write pb again from scratch, I would use filesystem apis instead.
Ctrl+C disconnects the process. Sorry, I'm new to linux.
I suggest reading about Ctrl-Z, bg
, fg
and other job control commands. https://www.digitalocean.com/community/tutorials/how-to-use-bash-s-job-control-to-manage-foreground-and-background-processes appears to be a fairly concise explanation.
Will pastes persist if I restart the docker container?
Pastes will persist. You can control this behavior with --no-recreate
and --force-recreate
accordingly. Keep in mind there is a strict terminology difference between container
and container image
. Restarting a process in a container is conceptually/literally the same thing as restarting a process anywhere else. When you create a new container from a new container image, the new container has no knowledge of and is completely separated from data that might exist elsewhere (this is by design).
from pb.
as for mongo backup, you may want to use my tool: https://github.com/glensc/docker-mongodb-hotbackup
but it may require you to use percona version of mongodb to have hotbackup support
from pb.
That error happens because you are building from a non-git source, which is not supported for the build method you are attempting. This is fully explained with relevant github-specific information in the message.
Make sure you clone pb with git clone https://github.com/ptpb/pb
.
from pb.
Alernately, if your issue is you don't have git for some reason, you can use this dockerfile instead of the one that ships in the repo:
FROM python:3.6-alpine
WORKDIR /pb
RUN apk add --no-cache --virtual .build-deps git
RUN git clone https://github.com/ptpb/pb /build
RUN pip install /build
RUN apk del .build-deps
CMD ["python", "-m", "pb"]
from pb.
That error happens because you are building from a non-git source, which is not supported for the build method you are attempting. This is fully explained with relevant github-specific information in the message.
Make sure you clone pb with
git clone https://github.com/ptpb/pb
.
Thank you so much. Works now.
However, I'm not finding any way to go to back to the terminal to execute commands. Ctrl+C
disconnects the process. Sorry, I'm new to linux.
https://pasteboard.co/IfTqHWk.jpg
Also, could you tell me where the pastes are stored? In mongodb or unix file system? Will pastes persist if I restart the docker container?
from pb.
@glensc indeed, thanks for reminding me!
from pb.
Thanks for your detailed reply.
Pastes are stored entirely mongodb
Is there any way I can limit the size of the pastes that the API can accept (say less than 1 MB or so) and is it possible to accept pastes only from a specific host?
from pb.
Is there any way I can limit the size of the pastes that the API can accept (say less than 1 MB or so)
and is it possible to accept pastes only from a specific host?
Both of these can be done with nginx.
http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size
https://docs.nginx.com/nginx/admin-guide/security-controls/controlling-access-proxied-tcp/
You could look at https://github.com/ptpb/ptpb-deploy/blob/11b6485f55a77d8328ca96d5295cb187f7797a29/openresty/ptpb.conf#L18-L43 for a good starting point; ignore lines 26-28.
from pb.
@buhman - Thank you.
from pb.
Pastes will persist. You can control this behavior with
--no-recreate
and--force-recreate
accordingly. Keep in mind there is a strict terminology difference betweencontainer
andcontainer image
. Restarting a process in a container is conceptually/literally the same thing as restarting a process anywhere else. When you create a new container from a new container image, the new container has no knowledge of and is completely separated from data that might exist elsewhere (this is by design).
Sorry I'm not really familiar with docker terminology. Is there any way I can ensure that all pastes persists if something unexpected happens? How can I take backup of mongodb?
Thanks.
from pb.
How can I take backup of mongodb?
You'll want to use "docker volumes". This is explained in the context of mongo in https://hub.docker.com/_/mongo
For example,
docker run -v /my/own/datadir:/data/db -d mongo
Would start a container using the mongo
image, with /my/own/datadir
on the host mapped to /data/db
in the container. /data/db
is where the mongo image stores its data by default.
In docker-compose, this would be:
mongodb:
image: mongo:latest
volumes:
- '/local/db/path:/data/db'
from pb.
How can I take backup of mongodb?
A backup can be a cp/rsync of the local /data/db
, as long as mongod is stopped while the copy operation is in progress. https://docs.mongodb.com/manual/core/backups/ also suggests using filesystem snapshots to avoid this offline requirement.
A third alternative is to use mongodump as also described there, but I suggested filesystem-based backups as mongodump/restore are somewhat (albeit bearably) slow if you have a huge database such as ptpb.pw's. You would use docker exec
to start mongodump inside the container.
from pb.
Thank you for the detailed response.
from pb.
Related Issues (20)
- IP upload black/whitelist HOT 1
- Pygments styles not applied propperly for dark background styles HOT 2
- ptpb.pw has AAAA record but address is not reachable HOT 2
- Web form doesn't give usable data HOT 2
- Can we append to an existing url ? HOT 2
- ptpb.pw data retention policy HOT 2
- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-x6n4bc2r/ HOT 2
- ptpb.pw is out of disk space HOT 4
- What does "ptpb.pw" mean? HOT 1
- how to add the command executed in the paste HOT 9
- post request header storage and replay HOT 8
- update won't work HOT 1
- ptpb.pw 500 Internal Server Error on uploading png HOT 11
- ptpb.pw permanent shutdown HOT 38
- ModuleNotFoundError: No module named 'werkzeug' when creating new container HOT 6
- Site is down HOT 5
- Sqlite Option HOT 3
- Docker-compose deployment HOT 3
- Question: Private paste vs Non-private paste HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pb.