Skip to content

Commit

Permalink
Merge pull request #8 from degauss-org/tiger-2019
Browse files Browse the repository at this point in the history
v3 release
  • Loading branch information
erikarasnick authored May 12, 2021
2 parents d2ca079 + 2d7e17a commit d3e820e
Show file tree
Hide file tree
Showing 22 changed files with 6,781 additions and 1,701 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ src/liblwgeom/liblwgeom.a
*.log
geocoding.html
.DS_Store
geocoder.db
geocoder_2019.db
test/cache
.Rproj.user
.Rhistory
geocoder.Rproj
test/d_for_geocoding.rds
test/geocoding_cache/
test/tmp*
69 changes: 32 additions & 37 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,58 +1,53 @@
FROM ubuntu:14.04
FROM ubuntu:20.04

MAINTAINER Cole Brokamp [email protected]

RUN useradd docker \
&& mkdir /home/docker \
&& chown docker:docker /home/docker \
&& addgroup docker staff
ADD https://geomarker.s3.us-east-2.amazonaws.com/geocoder_2019.db /opt/geocoder.db
# COPY geocoder_2019.db /opt/geocoder.db

RUN apt-get update && apt-get install -y \
libssl-dev \
libssh2-1-dev \
libcurl4-openssl-dev \
libxml2-dev \
git \
make \
wget \
nano \
sqlite3 \
libsqlite3-dev \
flex \
ruby-full ruby-rubyforge \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ruby-full \
bison \
gnupg \
software-properties-common \
&& apt-get clean

RUN wget https://colebrokamp-dropbox.s3.amazonaws.com/geocoder.db -P /opt
RUN gem install sqlite3 json Text

RUN echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list \
&& apt-get update \
&& apt-get install r-base-core -y --force-yes \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN mkdir /root/geocoder
WORKDIR /root/geocoder

RUN echo 'options(repos=c(CRAN = "https://cran.rstudio.com/"), download.file.method="wget")' >> /etc/R/Rprofile.site
COPY Makefile.ruby .
COPY /src ./src
COPY /lib ./lib
COPY /gemspec ./gemspec

RUN sudo su - -c "R -e \"install.packages(c('devtools','argparser'))\""
RUN sudo su - -c "R -e \"devtools::install_github('cole-brokamp/CB')\""
RUN cd /root/geocoder \
&& make -f Makefile.ruby install \
&& gem install Geocoder-US-2.0.4.gem

# need Ruby 3 for the gems
RUN apt-get update && apt-get install -y apt-file \
&& apt-file update \
&& apt-get install software-properties-common -y \
&& apt-add-repository ppa:brightbox/ruby-ng \
&& apt-get update \
&& apt-get install ruby2.2 ruby2.2-dev -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 \
&& add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/' \
&& apt update \
&& apt install -y r-base r-base-dev

RUN gem install sqlite3 json Text
# install required version of renv
RUN R --quiet -e "install.packages('remotes', repos = 'https://packagemanager.rstudio.com/all/__linux__/focal/latest')"
# make sure version matches what is used in the project: packageVersion('renv')
ENV RENV_VERSION 0.13.2
RUN R --quiet -e "remotes::install_github('rstudio/renv@${RENV_VERSION}')"

RUN mkdir /root/geocoder
COPY . /root/geocoder
COPY renv.lock .
RUN R --quiet -e "renv::restore(repos = c(CRAN = 'https://packagemanager.rstudio.com/all/__linux__/focal/latest'))"

RUN cd /root/geocoder \
&& make install \
&& gem install Geocoder-US-2.0.4.gem
COPY geocode.R .
COPY geocode.rb .

ENTRYPOINT ["/root/geocoder/bin/geocode.R"]
ENTRYPOINT ["./geocode.R"]
43 changes: 33 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
all:
make -C src install
gem build gemspec
REGISTRY_HOST=docker.io
USERNAME=degauss
NAME=$(shell basename "$(CURDIR)")
IMAGE=$(REGISTRY_HOST)/$(USERNAME)/$(NAME)

test: all
ruby -Ilib tests/run.rb
.PHONY: build test shell release clean

install: all
# gem install *.gem
build:
docker build -t $(IMAGE) .

test:
docker run --rm -v "${PWD}/test":/tmp $(IMAGE) my_address_file.csv

shell:
docker run --rm -it --entrypoint=/bin/bash -v "${PWD}/test":/tmp $(IMAGE)

release:
ifndef VERSION
$(error VERSION is not set. Usage: "make release VERSION=X.X")
endif
ifndef DOCKER_USERNAME
$(error DOCKER_USERNAME is not set)
endif
ifndef DOCKER_PAT
$(error DOCKER_PAT is not set)
endif
git commit -am "Release for image version $(VERSION)" --allow-empty
git tag -a $(VERSION) -m "${VERSION}"
git push origin ${VERSION}
git push
echo "${DOCKER_PAT}" | docker login -u "${DOCKER_USERNAME}" --password-stdin
docker tag ${IMAGE}:latest ${IMAGE}:${VERSION}
docker push ${IMAGE}:${VERSION}
docker push ${IMAGE}:latest

clean:
make -C src clean
rm -f lib/geocoder/us/sqlite3.so
rm -f *.gem
docker system prune -f
14 changes: 14 additions & 0 deletions Makefile.ruby
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
all:
make -C src install
gem build gemspec

test: all
ruby -Ilib tests/run.rb

install: all
# gem install *.gem

clean:
make -C src clean
rm -f lib/geocoder/us/sqlite3.so
rm -f *.gem
Loading

0 comments on commit d3e820e

Please sign in to comment.