diff --git a/.woodpecker/build.yaml b/.woodpecker/build.yaml new file mode 100644 index 0000000..88083af --- /dev/null +++ b/.woodpecker/build.yaml @@ -0,0 +1,32 @@ +steps: + - name: publish_image + image: woodpeckerci/plugin-docker-buildx + settings: + repo: git.gnous.eu/${CI_REPO_OWNER}/plakken + dockerfile: docker/Dockerfile + platforms: linux/amd64,linux/arm64/v8,linux/arm + registry: https://git.gnous.eu + tag: ${CI_COMMIT} + username: + from_secret: docker_username + password: + from_secret: docker_password + when: + branch: ${CI_REPO_DEFAULT_BRANCH} + event: push + - name: publish_image_tag + image: woodpeckerci/plugin-docker-buildx + settings: + repo: git.gnous.eu/${CI_REPO_OWNER}/plakken + dockerfile: docker/Dockerfile + platforms: linux/amd64,linux/arm64/v8,linux/arm + registry: https://git.gnous.eu + tags: + - ${CI_COMMIT_TAG##v} # Remove v from tag + - stable + username: + from_secret: docker_username + password: + from_secret: docker_password + when: + event: tag diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..f50175c --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,28 @@ +# Build +FROM golang:1.22 AS build +LABEL authors="gnousEU" + +WORKDIR /build + +COPY go.mod go.sum ./ +RUN go mod download + +COPY main.go ./ +COPY internal/ ./internal +COPY static/ ./static +COPY templates/ ./templates + +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-w -s" # Enable static binary, target Linux, remove debug information and strip binary + +# Copy to our image +FROM gcr.io/distroless/static-debian12:nonroot + +WORKDIR /app + +COPY --from=build /build/plakken ./ + +ENV PLAKKEN_LISTEN ":3000" + +EXPOSE 3000/tcp + +ENTRYPOINT ["/app/plakken"] diff --git a/docker/docker-compose.dev.yaml b/docker/docker-compose.dev.yaml new file mode 100644 index 0000000..8ec1e6e --- /dev/null +++ b/docker/docker-compose.dev.yaml @@ -0,0 +1,31 @@ +version: "3" + +networks: + plakken: + external: false + +services: + server: + build: + context: ../ + dockerfile: docker/Dockerfile + restart: always + container_name: plakken + networks: + - plakken + ports: + - "3000:3000" + environment: + - PLAKKEN_REDIS_ADDRESS=redis:6379 + - POSTGRES_PASSWORD=gitea + - PLAKKEN_REDIS_DB=0 + - PLAKKEN_URL_LENGTH=5 + depends_on: + - redis + redis: + image: redis:7-alpine + restart: always + healthcheck: + test: [ "CMD", "redis-cli", "ping" ] + networks: + - plakken diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml new file mode 100644 index 0000000..1dc30b0 --- /dev/null +++ b/docker/docker-compose.yaml @@ -0,0 +1,36 @@ +version: "3" + +networks: + plakken: + external: false + +volumes: + redis: + driver: local + +services: + server: + image: git.gnous.eu/gnouseu/plakken:latest + restart: always + container_name: plakken + read_only: true + networks: + - plakken + ports: + - "3000:3000" + environment: + - PLAKKEN_REDIS_ADDRESS=redis:6379 + - POSTGRES_PASSWORD=gitea + - PLAKKEN_REDIS_DB=0 + - PLAKKEN_URL_LENGTH=5 + depends_on: + - redis + redis: + image: redis:7-alpine + restart: always + healthcheck: + test: [ "CMD", "redis-cli", "ping" ] + networks: + - plakken + volumes: + - redis:/data