<commit_before># Secrets with OpenFaaS and Docker Swarm

OpenFaaS deploys functions as Docker Swarm Services, as result there are several features that we can leverage to simplify the development and subsquent deployment of functions to hardened production environments.

## Using Environment Variables

First, and least secure, is the ability to set environment variables at deploy time. For example, you might want to set the `NODE_ENV` or `DEBUG` variable.  Setting the `NODE_ENV` in the stack file `samples.yml`
```yaml
provider:
  name: faas
  gateway: http://localhost:8080

functions:
  nodehelloenv:
    lang: Dockerfile
    skip_build: true
    image: functions/nodehelloenv:latest
    environment:
        NODE_ENV: production
```

You can then deploy and invoke the function via the `faas-cli` using
```sh
$ faas-cli deploy -f ./samples.yml
$ fass-cli invoke nodehelloenv
Hello from a production machine
```

Notice that it is using the value of `NODE_ENV` from the stack file, the default is is `dev`.


## Using Swarm Secrets
<commit_msg>Fix typo suggested by community.<commit_after># Secrets with OpenFaaS and Docker Swarm

OpenFaaS deploys functions as Docker Swarm Services, as result there are several features that we can leverage to simplify the development and subsquent deployment of functions to hardened production environments.

## Using Environment Variables

First, and least secure, is the ability to set environment variables at deploy time. For example, you might want to set the `NODE_ENV` or `DEBUG` variable.  Setting the `NODE_ENV` in the stack file `samples.yml`
```yaml
provider:
  name: faas
  gateway: http://localhost:8080

functions:
  nodehelloenv:
    lang: Dockerfile
    skip_build: true
    image: functions/nodehelloenv:latest
    environment:
        NODE_ENV: production
```

You can then deploy and invoke the function via the `faas-cli` using
```sh
$ faas-cli deploy -f ./samples.yml
$ faas-cli invoke nodehelloenv
Hello from a production machine
```

Notice that it is using the value of `NODE_ENV` from the stack file, the default is is `dev`.


## Using Swarm Secrets

{'fraction_non_alphanumeric': 0.06553512494106553, 'fraction_numerical': 0.003771805752003772, 'mean_word_length': 4.305, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3202098', 'n_tokens_mistral': 606, 'n_tokens_neox': 567, 'n_words': 278}