Skip to content

Commit

Permalink
Prepare Dockerfile for K8S
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvain-morin committed Feb 9, 2024
1 parent 6be9296 commit 5dadd43
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 4 deletions.
24 changes: 20 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,31 @@ FROM node:16

ENV NODE_ENV=development

WORKDIR /usr/src/app
RUN useradd -ms /bin/bash inaturalist
USER inaturalist

COPY package*.json ./
# Set the working directory in the container
WORKDIR /home/inaturalist/api

COPY config_example.js config.js
# Copy the dependencies file to the working directory
COPY --chown=inaturalist:inaturalist package*.json .
COPY --chown=inaturalist:inaturalist config.docker.js config.js

# Install dependencies
RUN npm install

COPY . .
# Copy app and libs
COPY --chown=inaturalist:inaturalist lib lib
COPY --chown=inaturalist:inaturalist openapi openapi
COPY --chown=inaturalist:inaturalist public public
COPY --chown=inaturalist:inaturalist schema schema
COPY --chown=inaturalist:inaturalist swagger-ui swagger-ui
COPY --chown=inaturalist:inaturalist app.js .

# Create directories for the log and static content
RUN mkdir /home/inaturalist/api/log
RUN mkdir /home/inaturalist/api/cache
RUN mkdir -p /home/inaturalist/api/public/uploads

EXPOSE 4000

Expand Down
70 changes: 70 additions & 0 deletions config.docker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
var fs = require( "fs" );

Check failure on line 1 in config.docker.js

View workflow job for this annotation

GitHub Actions / build-and-test / Build/Test

Unexpected var, use let or const instead

const {
INAT_DB_HOST,

Check failure on line 4 in config.docker.js

View workflow job for this annotation

GitHub Actions / build-and-test / Build/Test

Expected indentation of 2 spaces but found 4
INAT_DB_USER,

Check failure on line 5 in config.docker.js

View workflow job for this annotation

GitHub Actions / build-and-test / Build/Test

Expected indentation of 2 spaces but found 4
INAT_DB_PASS,

Check failure on line 6 in config.docker.js

View workflow job for this annotation

GitHub Actions / build-and-test / Build/Test

Expected indentation of 2 spaces but found 4
INAT_ES_HOST,

Check failure on line 7 in config.docker.js

View workflow job for this annotation

GitHub Actions / build-and-test / Build/Test

Expected indentation of 2 spaces but found 4
INAT_REDIS_HOST,

Check failure on line 8 in config.docker.js

View workflow job for this annotation

GitHub Actions / build-and-test / Build/Test

Expected indentation of 2 spaces but found 4
INAT_API_URL,

Check failure on line 9 in config.docker.js

View workflow job for this annotation

GitHub Actions / build-and-test / Build/Test

Expected indentation of 2 spaces but found 4
INAT_RAILS_URL,

Check failure on line 10 in config.docker.js

View workflow job for this annotation

GitHub Actions / build-and-test / Build/Test

Expected indentation of 2 spaces but found 4
INAT_VISION_URL,

Check failure on line 11 in config.docker.js

View workflow job for this annotation

GitHub Actions / build-and-test / Build/Test

Expected indentation of 2 spaces but found 4
INAT_DB_SSL_KEY_PATH,

Check failure on line 12 in config.docker.js

View workflow job for this annotation

GitHub Actions / build-and-test / Build/Test

Expected indentation of 2 spaces but found 4
INAT_DB_SSL_CRT_PATH,
INAT_STATIC_IMAGE_URL,
INAT_JWT_SECRET,
INAT_JWT_APPLICATION_SECRET,
INAT_AWS_OPENDATA_BUCKET,
INAT_AWS_OPENDATA_DOMAIN,
INAT_AWS_OPENDATA_REGION,
INAT_AWS_OPENDATA_ACL,
INAT_TAXA_FILE_PATH
} = process.env;

module.exports = {
environment: NODE_ENV || "development",
currentVersionURL: INAT_API_URL || "http://localhost:4000/v1",
apiURL: INAT_RAILS_URL || "http://localhost:3000",
jwtSecret: INAT_JWT_SECRET || "secret",
jwtApplicationSecret: INAT_JWT_APPLICATION_SECRET || "application_secret",
tileSize: 512,
debug: false,
database: {
user: INAT_DB_USER || "inaturalist",
host: INAT_DB_HOST || "127.0.0.1",
port: 5432,
geometry_field: "geom",
srid: 4326,
password: INAT_DB_PASS || "inaturalist",
ssl: ( INAT_DB_SSL_KEY_PATH && INAT_DB_SSL_CRT_PATH ) ? {
rejectUnauthorized: false,
key: fs.readFileSync( INAT_DB_SSL_KEY_PATH ),
cert: fs.readFileSync( INAT_DB_SSL_CRT_PATH )
} : false
},
staticImagePrefix: INAT_STATIC_IMAGE_URL || "http://localhost:3000/attachments/",
websiteURL: INAT_RAILS_URL ? `${INAT_RAILS_URL}/` : "http://localhost:3000/",
imageProcesing: {
tensorappURL: INAT_VISION_URL || "http://localhost:6006",
uploadsDir: "/home/inaturalist/api/public/uploads",
taxaFilePath: INAT_TAXA_FILE_PATH || "",
geomodel: true,
combinedThreshold: 0.001,
frequencyBackend: "redis"
},
redis: {
host: INAT_REDIS_HOST || "127.0.0.1",
port: 6379
},
aws: {
openDataBucket: INAT_AWS_OPENDATA_BUCKET || "staticdev-public",
openDataDomain: INAT_AWS_OPENDATA_DOMAIN || "staticdev-public.s3.amazonaws.com",
openDataRegion: INAT_AWS_OPENDATA_REGION || "us-east-1",
openDataACL: INAT_AWS_OPENDATA_ACL ||"",
},
elasticsearch: {
host: INAT_ES_HOST ? `http://${INAT_ES_HOST}:9200` : "http://localhost:9200"
},
cacheDir: "/home/inaturalist/api/cache",
seekExceptionListID: 945029
}

0 comments on commit 5dadd43

Please sign in to comment.