Skip to content

Commit

Permalink
Add basic dockerization
Browse files Browse the repository at this point in the history
  • Loading branch information
aleda145 committed Aug 3, 2022
1 parent 35104d2 commit db761dc
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
39 changes: 39 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM golang:1.19-buster as builder

# build
WORKDIR /app

COPY go.mod ./
COPY go.sum ./

RUN go mod download

COPY ./pocketbase ./pocketbase
RUN go build -o /pocketbase pocketbase/main.go
#checkov:skip=CKV_DOCKER_4: Ensure that COPY is used instead of ADD in Dockerfiles
# Because we want to add from a remote URL, and there is no reason not to trust benbjohnson
# ADD https://github.com/benbjohnson/litestream/releases/download/v0.3.8/litestream-v0.3.8-linux-amd64-static.tar.gz /tmp/litestream.tar.gz
# RUN tar -C /usr/local/bin -xzf /tmp/litestream.tar.gz

# deploy
FROM debian:buster-slim
RUN set -x && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates=20200601~deb10u2 && \
rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY --from=builder /pocketbase /pocketbase
# COPY --from=builder /usr/local/bin/litestream /usr/local/bin/litestream
# COPY litestream.yml /etc/litestream.yml

COPY run.sh .


EXPOSE 8090
# TODO add a health check to the API
HEALTHCHECK NONE
#checkov:skip=CKV_DOCKER_3: Ensure that a user for the container has been created
# Because it will run as root on the VM anyway, and there is nothing else there but a docker container

CMD ["/app/run.sh"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions backend/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -e

echo "Check diskspace on VM"
df -h

# echo "litestream version"
# litestream version

# # Docker entry point for image will decode the base64 secret and put it into the GOOGLE_APPLICATION_CREDENTIALS PATH that has been specified
# # this has to be done before litestream starts!
# # Should be no issue with the correct entrypoint
# # then it can be used by flyctl secrets as well
# # https://www.avaitla16.com/google-application-credentials-json-as-an-environment-variable
# # https://community.fly.io/t/how-are-you-managing-cert-files-with-fly/2984/20

# echo "set gcp key"
# echo "$GCP_KEY" | base64 -d > "$GOOGLE_APPLICATION_CREDENTIALS"

# echo "Restore db if exists"
# litestream restore -if-replica-exists /app/production.db

# echo "replicate!"
# exec litestream replicate -exec "/api"
/pocketbase serve --http 0.0.0.0:8090

0 comments on commit db761dc

Please sign in to comment.