Skip to content

Commit

Permalink
Merge pull request #4 from snguyen1/optimize-image-size
Browse files Browse the repository at this point in the history
Optimize image size
  • Loading branch information
snguyen1 committed Jul 22, 2021
2 parents d6de281 + bd65632 commit 1a9ef06
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 37 deletions.
2 changes: 2 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
HOST_DATA_ABS_DIR="/abs/path/to/data/dir"
HOST_SCRIPT_ABS_DIR="/abs/path/to/script/dir"
32 changes: 32 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Docker Hub Push
on:
push:
# Publish semver tags as releases.
tags: [ '*' ]

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
pull: true
cache-from: type=registry,ref=sondngyn/wgrib2:latest
cache-to: type=inline
tags: sondngyn/wgrib2:latest
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.env
data/*
.env
data
script
25 changes: 12 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,20 @@ RUN apt-get update && apt-get install -y \
bzip2 \
tar \
amqp-tools \
openssh-client

RUN apt-get install -y \
openssh-client \
gfortran \
--no-install-recommends && rm -r /var/lib/apt/lists/*
RUN wget ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/wgrib2.tgz -O /tmp/wgrib2.tgz
RUN mkdir -p /usr/local/grib2/
RUN tar -xf /tmp/wgrib2.tgz -C /tmp/
RUN rm -r /tmp/wgrib2.tgz
RUN mv /tmp/grib2/ /usr/local/grib2/
RUN cd /usr/local/grib2/grib2 && make
RUN ln -s /usr/local/grib2/grib2/wgrib2/wgrib2 /usr/local/bin/wgrib2
RUN apt-get -y autoremove build-essential
--no-install-recommends && rm -r /var/lib/apt/lists/* \
&& wget ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/wgrib2.tgz -O /tmp/wgrib2.tgz \
&& mkdir -p /usr/local/grib2/ \
&& tar -xf /tmp/wgrib2.tgz -C /tmp/ \
&& rm -r /tmp/wgrib2.tgz \
&& mv /tmp/grib2/ /usr/local/grib2/ \
&& cd /usr/local/grib2/grib2 && make \
&& ln -s /usr/local/grib2/grib2/wgrib2/wgrib2 /usr/local/bin/wgrib2 \
&& apt-get -y autoremove build-essential

VOLUME /srv/
VOLUME /opt/
WORKDIR /opt/
CMD ["/bin/bash", "entrypoint.sh"]
ENTRYPOINT [ "/bin/bash" ]
CMD ["/opt/entrypoint.sh"]
45 changes: 23 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
WGRIB2 on Container (Debian Bulleyes)
### Note: I update the container based on: https://hub.docker.com/r/bearstudio/wgrib/
## USAGE

### Build:
`docker build -t sondngyn/wgrib2 .`
### On Linux:
`docker run -v /path/to/data:/srv/ -v /path/to/script:/opt/ sondngyn/wgrib2 /opt/script_file_name.sh`
### On Windows:
*Note:
Remember to put `#!bin/bash` in the beginning of your script file
Make sure your script file uses LF (Linux line break types) instead of CRLF (Windows). You can easily change it on VS Code
`docker run -v C:\absolute\path\to\data\dir\:/srv/ -v C:\absolute\path\to\script\dir\:/opt/ sondngyn/wgrib2 /opt/script_file_name.sh`
(watch out for back-slashes and forward-slashes)
### Example on Windows (powershell):
`docker run -v C:\Users\myuser\mydata\:/srv/ -v C:\Users\myuser\myscript\:/opt/ sondngyn/wgrib2 /opt/myscript.sh`

## DEV:
0. Clean up: `docker container rm wgrib2 -f`
1. Build image: `docker build -t wgrib2 .`
2. Spin up container: `docker run --rm --name wgrib2 -d -it wgrib2`
3. Exec: `docker exec -it wgrib2 bash`
WGRIB2 on Container (Debian Bulleyes)
### Note: I update the container based on: https://hub.docker.com/r/bearstudio/wgrib/
## USAGE

### Usage:

#### Docker-Compose CLI
Create `.env` file from `.env.dist` and change the env values to the dirs location on your computer (for windows, use `/c/abs/path/`)
`docker-compose build wgrib2`
`docker-compose up wgrib2` (change `command` in docker-compose file to your script filename before running `up`)

#### Docker CLI
`docker build -t wgrib2 .`
##### On Linux:
`docker run -v /path/to/data:/srv/ -v /path/to/script:/opt/ sondngyn/wgrib2 /opt/script_file_name.sh`
##### On Windows:
*Note:
Remember to put `#!bin/bash` in the beginning of your script file
Make sure your script file uses LF (Linux line break types) instead of CRLF (Windows)
`docker run -v C:\\absolute\\path\\:/srv/ -v C:\\absolute\\path\\:/opt/ wgrib2 script_file_name.sh`
(watch out for back-slashes and forward-slashes)
### Example on Windows (powershell):
`docker run -v C:\\Users\\myuser\\mydata\\:/srv/ -v C:\\Users\\myuser\\myscript\\:/opt/ wgrib2 myscript.sh`
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: "3.8"

services:
wgrib2:
image: wgrib2
container_name: wgrib2
restart: unless-stopped
env_file: ./.env
entrypoint: /bin/bash
# Change this command to your bash script filename
command: "/srv/script.sh"
build:
context: ./
volumes:
- type: bind
source: ${HOST_DATA_ABS_DIR}
target: /opt/
- type: bind
source: ${HOST_SCRIPT_ABS_DIR}
target: /srv/

0 comments on commit 1a9ef06

Please sign in to comment.