Skip to content

Commit

Permalink
feat(nat): build & release docker images. (#162)
Browse files Browse the repository at this point in the history
* feat(nat): build & release docker images.
  • Loading branch information
scharissis authored Feb 6, 2025
1 parent 4bfac46 commit 5451561
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 5 deletions.
21 changes: 19 additions & 2 deletions .circleci/continue_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ jobs:
echo "run-build-pms: << pipeline.parameters.run-build-pms >>"
echo "run-build-op-ufm: << pipeline.parameters.run-build-op-ufm >>"
echo "run-build-proxyd: << pipeline.parameters.run-build-proxyd >>"
echo "run-build-op-nat: << pipeline.parameters.run-build-op-nat >>"
echo "run-all: << pipeline.parameters.run-all >>"
echo ""
echo "Pipeline Trigger Information:"
Expand Down Expand Up @@ -141,6 +142,13 @@ jobs:
else
echo "op-ufm tag regex match: false"
fi
if [[ $CURRENT_TAG =~ ^op-nat/v.* ]]; then
echo "op-nat tag regex match: true"
else
echo "op-nat tag regex match: false"
fi
docker-build:
environment:
DOCKER_BUILDKIT: 1
Expand Down Expand Up @@ -521,19 +529,25 @@ workflows:
- go-test:
name: op-nat-tests
module: op-nat
- docker-build:
name: op-nat-docker-build
docker_file: op-nat/Dockerfile
docker_name: op-nat
docker_tags: <<pipeline.git.revision>>,<<pipeline.git.branch>>
docker_context: .
release:
jobs:
- log-config-results:
filters:
tags:
only: /^(cci-stats|peer-mgmt-service|proxyd|ufm-[a-z0-9\-]*|op-[a-z0-9\-]*)\/v.*/
only: /^(op-nat|cci-stats|peer-mgmt-service|proxyd|ufm-[a-z0-9\-]*|op-[a-z0-9\-]*)\/v.*/
branches:
ignore: /.*/
- hold:
type: approval
filters:
tags:
only: /^(cci-stats|peer-mgmt-service|proxyd|ufm-[a-z0-9\-]*|op-[a-z0-9\-]*)\/v.*/
only: /^(op-nat|cci-stats|peer-mgmt-service|proxyd|ufm-[a-z0-9\-]*|op-[a-z0-9\-]*)\/v.*/
branches:
ignore: /.*/
- docker-build:
Expand All @@ -547,6 +561,7 @@ workflows:
- op-conductor-mon
- peer-mgmt-service
- cci-stats
- op-nat
name: <<matrix.docker_name>>-docker-build
filters:
tags:
Expand All @@ -569,6 +584,7 @@ workflows:
- op-conductor-mon
- peer-mgmt-service
- cci-stats
- op-nat
name: <<matrix.docker_name>>-docker-publish
filters:
tags:
Expand All @@ -589,6 +605,7 @@ workflows:
- op-conductor-mon
- peer-mgmt-service
- cci-stats
- op-nat
name: <<matrix.docker_name>>-docker-tag
filters:
tags:
Expand Down
8 changes: 8 additions & 0 deletions op-nat/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git
.gitignore
README.md
Dockerfile
*.md
*.log
bin/
tmp/
58 changes: 58 additions & 0 deletions op-nat/.goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2

project_name: op-nat

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy

builds:
- id: main
main: ./cmd/main
binary: bin/op-nat
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
ignore:
- goos: windows
goarch: arm64
- goos: linux
goarch: arm64
mod_timestamp: "{{ .CommitTimestamp }}"
ldflags:
- -X main.GitCommit={{ .FullCommit }}
- -X main.GitDate={{ .CommitDate }}
- -X main.Version={{ .Version }}

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: "{{ .ProjectName }}-{{.Version}}-{{ tolower .Os }}-{{ .Arch }}"
# use zip for windows archives
wrap_in_directory: true
format_overrides:
- goos: windows
format: zip

changelog:
sort: asc

release:
github:
owner: ethereum-optimism
name: infra
make_latest: false

monorepo:
tag_prefix: op-nat/
dir: op-nat
6 changes: 5 additions & 1 deletion op-nat/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
FROM golang:1.23.5-alpine3.21 AS builder

WORKDIR /app
COPY . .

# Install dependencies first for better caching
RUN apk add --no-cache just

COPY op-nat/ .

RUN just build

FROM alpine:3.21
Expand Down
4 changes: 3 additions & 1 deletion op-nat/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ services:

op-nat:
container_name: op-nat
build: .
build:
context: ..
dockerfile: op-nat/Dockerfile
volumes:
- ./devnets:/devnets
command: ["--kurtosis.devnet.manifest", "/devnets/simple-devnet.json"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ DOCKER_REPO=$1
GIT_TAG=$2
GIT_SHA=$3

IMAGE_NAME=$(echo "$GIT_TAG" | grep -Eow '^(cci-stats|peer-mgmt-service|proxyd|ufm-[a-z0-9\-]*|op-[a-z0-9\-]*)' || true)
IMAGE_NAME=$(echo "$GIT_TAG" | grep -Eow '^(op-nat|cci-stats|peer-mgmt-service|proxyd|ufm-[a-z0-9\-]*|op-[a-z0-9\-]*)' || true)
if [ -z "$IMAGE_NAME" ]; then
echo "image name could not be parsed from git tag '$GIT_TAG'"
exit 1
Expand Down

0 comments on commit 5451561

Please sign in to comment.