-
Notifications
You must be signed in to change notification settings - Fork 1
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 #1 from christopherime/main
Dockerfile image size optimisation
- Loading branch information
Showing
3 changed files
with
52 additions
and
6 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,29 @@ | ||
name: "CodeQL" | ||
on: | ||
push: | ||
branches: [ master ] | ||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: [ 'go' ] | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v2 | ||
with: | ||
languages: ${{ matrix.language }} | ||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@v2 | ||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v2 | ||
with: | ||
category: "/language:${{matrix.language}}" |
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
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 |
---|---|---|
@@ -1,11 +1,24 @@ | ||
FROM golang:1.21.1 | ||
FROM golang:1.21-alpine AS builder | ||
|
||
RUN mkdir -p /app | ||
ARG ARCH=amd64 | ||
|
||
WORKDIR /app | ||
ENV GOROOT /usr/local/go | ||
ENV GOPATH /go | ||
ENV PATH $GOPATH/bin:$GOROOT/bin:$PATH | ||
ENV GO_VERSION 1.21 | ||
ENV GO111MODULE on | ||
ENV CGO_ENABLED=0 | ||
|
||
ADD . /app | ||
# Build dependencies | ||
WORKDIR /go/src/ | ||
COPY . . | ||
RUN apk update && apk add make git | ||
RUN go get . | ||
RUN mkdir /go/src/build | ||
RUN go build -a -gcflags=all="-l -B" -ldflags="-w -s" -o build/p2c . | ||
|
||
RUN go build ./p2c.go | ||
# Second stage | ||
FROM alpine:3.19 | ||
|
||
CMD ["./p2c"] | ||
COPY --from=builder /go/src/build/p2c /usr/local/bin/p2c | ||
CMD ["/usr/local/bin/p2c"] |