Skip to content

Commit b636741

Browse files
committed
Add alpine Dockerfile
1 parent 8b22f27 commit b636741

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.bundle/
2+
.gem_rbs_collection/
3+
.git/
4+
.yardoc/
5+
doc/
6+
vendor/

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,19 @@ Run `bundle exec rake build_all`.
131131

132132
See `bundle exec rake -T` for more tasks.
133133

134+
### Build in docker container
135+
e.g.
136+
137+
```bash
138+
docker build --file=_dockerfiles/alpine.dockerfile -t go-gem-wrappper .
139+
# or
140+
docker build --file=_dockerfiles/alpine.dockerfile -t go-gem-wrappper --build-arg GO_VERSION=1.23 --build-arg RUBY_VERSION=3.4 .
141+
142+
docker run --rm -it go-gem-wrappper sh
143+
```
144+
145+
Run `bundle exec rake build_all` in container.
146+
134147
### See `godoc` in local
135148
```bash
136149
go install golang.org/x/tools/cmd/godoc@latest

_dockerfiles/alpine.dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
ARG GO_VERSION=1.23
2+
ARG RUBY_VERSION=3.4
3+
ARG ALPINE_VERSION=3.21
4+
5+
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS golang
6+
7+
FROM ruby:${RUBY_VERSION}-alpine${ALPINE_VERSION}
8+
9+
RUN apk update && \
10+
apk add --no-cache git alpine-sdk libffi-dev
11+
12+
COPY --from=golang /usr/local/go /usr/local/go
13+
COPY --from=golang /go /go
14+
15+
ENV PATH=/go/bin:/usr/local/go/bin:$PATH \
16+
GOPATH=/go \
17+
GOLANGCI_LINT_VERSION=v1.60.3
18+
19+
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s ${GOLANGCI_LINT_VERSION}
20+
21+
WORKDIR /app
22+
23+
COPY Gemfile Gemfile.lock ./
24+
COPY _gem/go_gem.gemspec _gem/
25+
COPY _gem/lib/go_gem/version.rb _gem/lib/go_gem/
26+
27+
RUN bundle config --local path vendor/bundle/ && \
28+
bundle config --local deployment true && \
29+
bundle install --jobs 4
30+
31+
COPY . .

0 commit comments

Comments
 (0)