-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Alistair1231/docker-support
add docker support
- Loading branch information
Showing
8 changed files
with
561 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Docker | ||
on: | ||
push: | ||
branches: | ||
- "*" | ||
|
||
tags: | ||
- "v*" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Build image | ||
run: docker buildx build --cache-to type=gha --cache-from type=gha -t image . | ||
|
||
- name: Push image | ||
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') | ||
run: | | ||
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
GITHUB_ID="ghcr.io/${{ github.repository }}" | ||
# Strip git ref prefix from version | ||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,' -e 's,^v,,') | ||
# Use Docker `latest` tag convention | ||
[ "$VERSION" == "main" ] && VERSION=latest | ||
set -x | ||
docker tag image $GITHUB_ID:$VERSION | ||
docker push $GITHUB_ID:$VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM perl:stable AS deps-test | ||
|
||
RUN cpanm Carton | ||
COPY cpanfile . | ||
COPY cpanfile.snapshot . | ||
RUN carton install && carton bundle | ||
|
||
FROM perl:stable | ||
COPY . . | ||
|
||
COPY --from=deps-test /usr/src/app/vendor/ ./vendor | ||
# Use version requirements from above, remove build artifacts after | ||
RUN cpanm --notest --from "$PWD/vendor/cache" --installdeps . && rm -rf ~/.cpanm vendor/ | ||
|
||
# This image needs a secret of 'serverauth' and a volume mounted at '/db'. | ||
RUN ln -sf /run/secrets/serverauth && ln -sf /db | ||
|
||
EXPOSE 5000 | ||
CMD ["./run-docker.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Docker compose file to run paste.sh locally. | ||
# | ||
# Optional, build (the image is published): | ||
# docker-compose build | ||
# | ||
# docker-compose --profile update-misc up | ||
# | ||
# Then visit http://localhost:5000 | ||
|
||
services: | ||
serverauth: | ||
image: davidgl/pastesh | ||
entrypoint: ["/bin/bash", "-c", "./generate-serverauth /work/serverauth"] | ||
volumes: | ||
- .:/work | ||
|
||
pastesh: | ||
depends_on: | ||
serverauth: | ||
condition: service_completed_successfully | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
image: davidgl/pastesh | ||
restart: unless-stopped | ||
# if you use a reverse proxy container, you can remove the port mapping. | ||
ports: | ||
- "5000:5000" | ||
volumes: | ||
- paste-db:/db | ||
secrets: | ||
- serverauth | ||
healthcheck: | ||
test: curl localhost:5000 | ||
start_period: 10s | ||
interval: 10s | ||
timeout: 2s | ||
retries: 3 | ||
# if use a reverse proxy container, you can uncomment the networks sections here, and below. | ||
#networks: | ||
# - apps | ||
|
||
update-misc: | ||
image: davidgl/pastesh | ||
# Use docker-compose --profile update-misc up to run this, note this will | ||
# use whatever is in davidgl/pastesh, so be careful to ensure you've built | ||
# it locally (i.e. docker-compose build), else you'll get the paste.sh | ||
# upstream misc data. | ||
profiles: | ||
- update-misc | ||
restart: no | ||
entrypoint: ["./update-misc"] | ||
depends_on: | ||
pastesh: | ||
condition: service_healthy | ||
network_mode: service:pastesh | ||
secrets: | ||
- serverauth | ||
|
||
#networks: | ||
# apps: | ||
# external: true | ||
|
||
volumes: | ||
paste-db: | ||
|
||
secrets: | ||
serverauth: | ||
file: ./serverauth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
requires 'JSON'; | ||
requires 'JSON::XS'; | ||
requires 'Tie::LevelDB'; | ||
requires 'Web::Simple'; | ||
requires 'Plack::Request'; | ||
requires 'Plack::Runner'; | ||
requires 'HTML::Entities'; | ||
requires 'Twiggy'; | ||
|
||
# Build dep of other things; somehow carton doesn't figure it out, so depend on it here... | ||
requires 'Module::Build::Tiny'; |
Oops, something went wrong.