Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created Dockerfile and updated ReadMe #121

Merged
merged 3 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
32 changes: 32 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Use the NODE_VERSION argument to specify the Node.js version
ARG NODE_VERSION=20

# Use the specified Node.js version as the base image
FROM node:${NODE_VERSION}-alpine

# Set Node args (do not set in node version 16 and below)
ENV NODE_OPTIONS=--openssl-legacy-provider
niklasmtj marked this conversation as resolved.
Show resolved Hide resolved

RUN apk add --update autoconf automake build-base libtool nasm pkgconf && \
rm -rf /var/cache/apk/*

# Setup work directory
WORKDIR /gitops-website

# Set permissions for non-root user
RUN chown -R node:node /gitops-website

# Switch user to non-root
USER node

# Add repo files with correct user:group ownership
ADD --chown=node:node . .
christianh814 marked this conversation as resolved.
Show resolved Hide resolved

# Install dependencies
RUN npm ci

# Expose port for server
EXPOSE 8000

# Create entrypoint
ENTRYPOINT ["npm", "start"]
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,15 @@ npm start
yarn install
yarn start
```

**Docker setup**
```shell
# Build container image from local filesystem with default Node version
docker build --no-cache -t website:<tag> -f Containerfile .

# Build container image from local filesystem with Node version as build arg
docker build --build-arg NODE_VERSION=19 --no-cache -t website:<tag> -f Containerfile .
niklasmtj marked this conversation as resolved.
Show resolved Hide resolved

# Run container image with mapping port 80 on your computer
docker run -dit -p 8000:8000 website:<tag>
```
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"scripts": {
"develop": "gatsby develop",
"start": "gatsby develop",
"start": "gatsby develop --host=0.0.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this æffect running it in production? (if at all) @niklasmtj

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't effect it at all since we're pushing the public folder to GH pages

"build": "gatsby build",
"serve": "gatsby serve",
"clean": "gatsby clean",
Expand Down Expand Up @@ -58,4 +58,4 @@
"postcss": "^8.3.5",
"tailwindcss": "^2.2.2"
}
}
}
Loading