Skip to content

Commit 667086d

Browse files
Merge pull request #10 from nsidc/re-add-nginx
Re-add nginx
2 parents 492bca3 + 453c46f commit 667086d

File tree

12 files changed

+194
-6
lines changed

12 files changed

+194
-6
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "Build and publish container image"
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
tags:
8+
- "v[0-9]+.[0-9]+.[0-9]+*"
9+
10+
jobs:
11+
build-and-release-server-image:
12+
name: "Build and release server container image"
13+
runs-on: "ubuntu-latest"
14+
env:
15+
IMAGE_NAME: "data-access-tool-server"
16+
# GitHub Actions expressions don't have great conditional support, so
17+
# writing a ternary expression looks a lot like bash. In Python, this
18+
# would read as:
19+
# github.ref_name if github.ref_type == 'tag' else 'latest'
20+
# https://docs.github.com/en/actions/learn-github-actions/expressions
21+
IMAGE_TAG:
22+
"${{ github.ref_type == 'tag' && github.ref_name || 'latest' }}"
23+
steps:
24+
- name: "Check out repository"
25+
uses: "actions/checkout@v4"
26+
27+
- name: "Build container image"
28+
run: |
29+
docker build --tag "ghcr.io/nsidc/${IMAGE_NAME}:${IMAGE_TAG}" nginx/
30+
31+
- name: "GHCR login"
32+
uses: "docker/login-action@v3"
33+
with:
34+
registry: "ghcr.io"
35+
username: "${{ github.repository_owner }}"
36+
password: "${{ secrets.GITHUB_TOKEN }}"
37+
38+
- name: "Push to image registries (DockerHub, GHCR)"
39+
run: |
40+
# Push to GHCR
41+
docker push "ghcr.io/nsidc/${IMAGE_NAME}:${IMAGE_TAG}"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
**/__pycache__/
2+
nginx/logs/*
23
docker-compose.override.yml

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v0.2.0
2+
3+
- Include nginx image build and configuration.
4+
15
# v0.1.0
26

37
- Initial release. This consititues an MVP for the DAT backend and includes

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ This repository provides:
1414
service required for DAT integration with the
1515
[NASA Earthdata Downloader](https://github.com/nasa/earthdata-download).
1616

17-
- Docker compose configuration for the DAT backend, which includes the
18-
[data-access-tool-server](https://github.com/nsidc/data-access-tool-ui).
17+
- Docker compose configuration for the DAT backend, which includes
18+
[nginx server configuration](./nginx).
1919

2020
## Background
2121

@@ -98,3 +98,17 @@ following query parameters:
9898

9999
> [!WARNING] As of this writing, the CMR query parameters are hard-coded to
100100
> always return a small subset of ATL06 v6 data.
101+
102+
## Releasing
103+
104+
To release a new version:
105+
106+
- Make changes on a branch
107+
- Update CHANGELOG for next release
108+
- Run `bump-my-version bump {major|minor|patch}`
109+
- Open a PR and have it merged to `main` after review
110+
- Tag latest commit on `main` with the version, and push. This will trigger a
111+
build of the `data-access-tool-api` and `data-access-tool-server` images with
112+
the given version tag.
113+
- Deploy the latest change with the
114+
[data-access-tool-vm](https://github.com/nsidc/data-access-tool-vm).

docker-compose.dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
command: '/bin/bash -c "PYTHONPATH=./ python dat_backend/app.py"'
77

88
server:
9-
build: ../data-access-tool-server/
9+
build: ./nginx
1010
volumes:
11-
- ../data-access-tool-server/logs:/var/log/nginx/
11+
- ./nginx/logs:/var/log/nginx/
1212
- ./nginx/edd_release/:/var/www/edd_release/

docker-compose.production.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
services:
22
api:
3-
image: "ghcr.io/nsidc/data-access-tool-api:v0.1.0"
3+
image: "ghcr.io/nsidc/data-access-tool-api:v0.2.0"
44
server:
5-
image: "ghcr.io/nsidc/data-access-tool-server:v0.1.0"
5+
image: "ghcr.io/nsidc/data-access-tool-server:v0.2.0"

environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ dependencies:
1717
- pyopenssl # required for test server w/ ssl
1818
- pre-commit ~=4.1
1919
- mypy ~=1.15
20+
- bump-my-version ~=1.1

nginx/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM nginx:1.27.4
2+
3+
RUN apt-get update && apt-get install -y openssl
4+
5+
RUN rm /etc/nginx/conf.d/default.conf
6+
COPY nginx.conf /etc/nginx/nginx.conf
7+
COPY dat.conf /etc/nginx/conf.d/
8+
9+
# TODO: remove when OBE. This allows exposing a pre-release of the EDD with the
10+
# trusted sources json file updated. Once
11+
# https://github.com/nasa/earthdata-download/pull/56 is merged, this can go
12+
# away.
13+
RUN mkdir -p /var/www/edd_release
14+
15+
RUN mkdir /etc/nginx/ssl && openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt -subj "/CN=nsidc"
16+
17+
RUN useradd --uid 1000 --user-group vagrant && \
18+
touch /var/run/nginx.pid && \
19+
chown -R vagrant:vagrant /var/run/nginx.pid && \
20+
chown -R vagrant:vagrant /var/cache/nginx && \
21+
chown -R vagrant:vagrant /etc/nginx

nginx/dat.conf

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
upstream api {
2+
server api:5000;
3+
}
4+
5+
server {
6+
listen 80;
7+
listen [::]:80;
8+
listen 443 default ssl;
9+
server_name dat;
10+
11+
ssl_certificate /etc/nginx/ssl/nginx.crt;
12+
ssl_certificate_key /etc/nginx/ssl/nginx.key;
13+
14+
if ($scheme = http) {
15+
return 301 https://$host$http_x_script_name;
16+
}
17+
18+
set $maintenance "off";
19+
if ($maintenance = "on") {
20+
return 503;
21+
}
22+
23+
set $env_host $host;
24+
if ($host = "localhost") {
25+
set $env_host "integration.nsidc.org";
26+
}
27+
28+
# index index.html index.htm index.php;
29+
30+
access_log /var/log/nginx/dat.access.log combined;
31+
error_log /var/log/nginx/dat.error.log debug;
32+
33+
sendfile off;
34+
35+
location "/" {
36+
proxy_pass https://api;
37+
proxy_read_timeout 90;
38+
proxy_connect_timeout 90;
39+
proxy_redirect off;
40+
client_max_body_size 500M;
41+
42+
proxy_set_header Host $host;
43+
proxy_set_header X-Real-IP $remote_addr;
44+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
45+
proxy_set_header X-Forwarded-Proto $scheme;
46+
proxy_set_header X-Script-Name $http_x_script_name;
47+
}
48+
49+
# TODO: remove when OBE. This allows exposing a pre-release of the EDD with
50+
# the trusted sources json file updated. Once
51+
# https://github.com/nasa/earthdata-download/pull/56 is merged, this can go
52+
# away.
53+
location "/earthdata-download-release" {
54+
alias /var/www/edd_release/;
55+
autoindex on; # Enables directory listing
56+
autoindex_exact_size off; # Show file sizes in a human-readable format
57+
}
58+
}

0 commit comments

Comments
 (0)