Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAFT: Enable remote debugging (DO NOT MERGE) #1011

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
strategy:
matrix:
service: [frontend,web,api,init]
debug_mode: ["-debug",""] # Conditional tag for debug images
fail-fast: false
runs-on: ubuntu-latest
steps:
Expand All @@ -55,9 +56,9 @@ jobs:
with:
images: ashirt/${{ matrix.service }} # list of Docker images to use as base name for tags
tags: |
type=sha
type=ref,event=branch
type=ref,event=pr
type=sha,suffix=${{ matrix.debug_mode }}
type=ref,event=branch,suffix=${{ matrix.debug_mode }}
type=ref,event=pr,suffix=${{ matrix.debug_mode }}
flavor: |
latest=false
- name: Login to Docker Hub
Expand All @@ -78,6 +79,7 @@ jobs:
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
platforms: linux/amd64
build-args: DEBUG=${{ matrix.debug_mode == '-debug' }} # True if "-debug", false if absent
push: true # Push with pr-### and sha-xxxxxxx tags

- name: Build and Push Latest
Expand Down
9 changes: 7 additions & 2 deletions Dockerfile.prod.web
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM golang:1.21-alpine AS build
ARG DEBUG=false

RUN apk add --no-cache git && \
rm -rf /var/cache/apk/*
Expand All @@ -11,18 +12,22 @@ RUN go mod download

COPY backend backend
COPY signer signer
RUN go build ./backend/bin/web/
RUN if [ $DEBUG == false ] ; then go build ./backend/bin/web/; else go build -gcflags "all=-N -l" ./backend/bin/web/; fi


FROM alpine:latest
ARG DEBUG=false
ENV DEBUG=$DEBUG

RUN apk add --no-cache ca-certificates && \
adduser -h /home/ashirt -S -D ashirt

RUN if [ $DEBUG == false ] ; then continue; else apk add --no-cache delve; fi

USER ashirt
WORKDIR /home/ashirt

COPY --from=build /build/web /home/ashirt/public-api
COPY backend/migrations /migrations

CMD /home/ashirt/public-api
CMD if [ $DEBUG == false ] ; then /home/ashirt/public-api ; else dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec /home/ashirt/public-api --continue ; fi
1 change: 1 addition & 0 deletions docker-compose-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
dockerfile: Dockerfile.prod.web
ports:
- 8000:8000
- 2345:2345
restart: on-failure
environment:
APP_CSRF_AUTH_KEY: "dummy-csrf-for-testing-prod-locally"
Expand Down
Loading