Closed luxiaba closed 2 years ago
I think for image packaging, we'd better only package code/project related data, and remove sensitive data.
Now dockerfile packages a sentive file (IPIP DB file) and that not submmited to git, and also config.py
, I think it's maybe a little not convenient for others to run, so I made some changes in the configuration part:
base.py
as the basic configuration of the project, and submit it to git.APP_ENV
to tell the project which configuration to load to overwrite base.py
.test.py
to git for testing usage.Pull.
docker pull ghcr.io/v2ex/remote@latest
You can have a try using my image first: docker pull ghcr.io/luxiaba/remote@latest
Run.
docker run -d --name v2ex-remote \
-e APP_ENV="PrOd" \
-v $PATH_TO_PROD_CONFIG:/app/remote/config/prod.py \
-v $PATH_TO_IPIP_DB:/opt/data/ipip.datx \
-p 127.0.0.1:5001:5000 \
$IMAGE_ID
# APP_ENV is case insentive.
# $PATH_TO_PROD_CONFIG is prod config file path.
# and $PATH_TO_IPIP_DB, IIRC it's should be map to `/opt/data/ipip.datx` in container.
# BTW, on the new version of macOS, 5000 is used by system services(airdrop or something) by default.
If everything is ok, we should can curl it now:
curl 127.0.0.1:5001/hello
A small change is needed.
I will add my Docker Hub username and a personal access token to the secrets.
Then we can push to v2ex/remote
on Docker Hub. Code is already open-sourced, so we can also publish it as v2ex/remote
on Docker Hub.
Two secrets are added:
Sure, so we push to both or just to docker hub?
Only Docker Hub.
So people can simply:
docker pull v2ex/remote
login-action did not work. I have set those as repository secrets:
It's a little strange. Let me check it first.
I will try to merge it first. Probably because PR cannot access secrets?
Yes, it's ture, success now. 🥳
Yes, after merging, it worked!
https://github.com/v2ex/remote/runs/4483982047?check_suite_focus=true
related #19
First of all, this is same as that PR about blueprint, I'm not sure if this is what you want, please feel free let me know if not fit. ☺️
Create a Github Token . Github Action should have permission to publish the image, we generate this token first, and make sure it has
write:packages
permission.Add token generated on step 1 to remote repo secrets . So that we can use it on Github Action, pls named it as
PACKAGES_TOKEN
(I call it this inci.yaml
for now).Merge to run CI.
Push to GHCR by Github Action. If everything is ok, at first time, CI will publish a new private image to GHCR, we can change it to public later.